<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta name="Content-Type" content="text/html; charset=utf-8" />
<title>Class: Ensembl::Core::Slice</title>
<link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '../..';
  if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>

  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="../../_index.html">Index (S)</a> &raquo; 
    <span class='title'><span class='object_link'><a href="../../Ensembl.html" title="Ensembl (module)">Ensembl</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Core.html" title="Ensembl::Core (module)">Core</a></span></span>
     &raquo; 
    <span class="title">Slice</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  <a id="class_list_link" href="#">Class List</a>
  <a id="method_list_link" href="#">Method List</a>
  <a id ="file_list_link" href="#">File List</a>
</div>

      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: Ensembl::Core::Slice
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Ensembl::Core::Slice</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">lib/ensembl/core/slice.rb<span class="defines">,<br />
  lib/ensembl/core/project.rb</span>
</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>
From the perl API tutorial
(http://www.ensembl.org/info/software/core/core_tutorial.html): &quot;A
Slice object represents a continuous region of a genome. Slices can be used
to obtain sequence, features or other information from a particular region
of interest.&quot;
</p>
<p>
In contrast to almost all other classes of Ensembl::Core, the Slice class
is not based on ActiveRecord.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='chr4 identifier id'>chr4</span> <span class='assign token'>=</span> <span class='SeqRegion constant id'>SeqRegion</span><span class='dot token'>.</span><span class='find_by_name identifier id'>find_by_name</span><span class='lparen token'>(</span><span class='string val'>'4'</span><span class='rparen token'>)</span>
<span class='my_slice identifier id'>my_slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='chr4 identifier id'>chr4</span><span class='comma token'>,</span> <span class='integer val'>95000</span><span class='comma token'>,</span> <span class='integer val'>98000</span><span class='comma token'>,</span> <span class='integer val'>-1</span><span class='rparen token'>)</span>
<span class='puts identifier id'>puts</span> <span class='my_slice identifier id'>my_slice</span><span class='dot token'>.</span><span class='display_name identifier id'>display_name</span>    <span class='comment val'>#--&gt; 'chromosome:4:Btau_3.1:95000:98000:1'</span>
</pre>
    
  </div>

</div>

  <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#seq-instance_method" title="#seq (instance method)">- (Bio::Sequence::NA) <strong>seq</strong> </a>
    

    
  </span>
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Get the sequence of the Slice as a Bio::Sequence::NA object.
</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#seq_region-instance_method" title="#seq_region (instance method)">- (Object) <strong>seq_region</strong> </a>
    

    
  </span>
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Returns the value of attribute seq_region.
</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#start-instance_method" title="#start (instance method)">- (Object) <strong>start</strong> </a>
    

    
  </span>
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Returns the value of attribute start.
</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#stop-instance_method" title="#stop (instance method)">- (Object) <strong>stop</strong> </a>
    

    
  </span>
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Returns the value of attribute stop.
</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#strand-instance_method" title="#strand (instance method)">- (Object) <strong>strand</strong> </a>
    

    
  </span>
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Returns the value of attribute strand.
</p>
</div></span>
  
</li>

    
  </ul>


  
    <h2>
      Class Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#fetch_all-class_method" title="fetch_all (class method)">+ (Array&lt;Slice&gt;) <strong>fetch_all</strong>(coord_system_name = 'chromosome', species = Ensembl::SESSION.collection_species, version = nil) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Create an array of all Slices for a given coordinate system.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#fetch_by_gene_stable_id-class_method" title="fetch_by_gene_stable_id (class method)">+ (Slice) <strong>fetch_by_gene_stable_id</strong>(gene_stable_id, flanking_seq_length = 0) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Create a Slice based on a Gene.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#fetch_by_region-class_method" title="fetch_by_region (class method)">+ (Slice) <strong>fetch_by_region</strong>(coord_system_name, seq_region_name, start = nil, stop = nil, strand = 1, species = Ensembl::SESSION.collection_species, version = nil) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Create a Slice without first creating the SeqRegion object.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#fetch_by_transcript_stable_id-class_method" title="fetch_by_transcript_stable_id (class method)">+ (Slice) <strong>fetch_by_transcript_stable_id</strong>(transcript_stable_id, flanking_seq_length = 0) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Create a Slice based on a Transcript.
</p>
</div></span>
  
</li>

      
    </ul>
  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#display_name-instance_method" title="#display_name (instance method)">- (String) <strong>display_name</strong> </a>
    

    
      (also: #to_s)
    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
The display_name method returns a full name of this slice, containing the
name of the coordinate system, the sequence region, start and stop
positions on that sequence region and the strand.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#dna_align_features-instance_method" title="#dna_align_features (instance method)">- (Array&lt;DnaAlignFeature&gt;) <strong>dna_align_features</strong>(analysis_name = nil) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Get all DnaAlignFeatures that are located on a Slice for a given Analysis.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#excise-instance_method" title="#excise (instance method)">- (Array&lt;Slice&gt;) <strong>excise</strong>(ranges) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
The Slice#excise method removes a bit of a slice and returns the remainder
as separate slices.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_genotyped_variation_features-instance_method" title="#get_genotyped_variation_features (instance method)">- (Object) <strong>get_genotyped_variation_features</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_objects-instance_method" title="#get_objects (instance method)">- (Object) <strong>get_objects</strong>(target_class, table_name, inclusive = false) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Don&#8217;t use this method yourself.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_structural_variations-instance_method" title="#get_structural_variations (instance method)">- (Object) <strong>get_structural_variations</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_variation_features-instance_method" title="#get_variation_features (instance method)">- (Object) <strong>get_variation_features</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Method to retrieve Variation features from Ensembl::Core::Slice objects.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (Slice) <strong>initialize</strong>(seq_region, start = 1, stop = seq_region.length, strand = 1) </a>
    

    
  </span>
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Create a new Slice object from scratch.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#length-instance_method" title="#length (instance method)">- (Integer) <strong>length</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Get the length of a slice.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#method_missing-instance_method" title="#method_missing (instance method)">- (Object) <strong>method_missing</strong>(method_name, *args) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
&#8212; As there should be &#8216;getters&#8217; for a lot of classes,
we&#8217;ll implement this with method_missing.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#misc_features-instance_method" title="#misc_features (instance method)">- (Array&lt;MiscFeature&gt;) <strong>misc_features</strong>(code) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Get all MiscFeatures that are located on a Slice for a given MiscSet.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#overlaps%3F-instance_method" title="#overlaps? (instance method)">- (Boolean) <strong>overlaps?</strong>(other_slice) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
The Slice#overlaps? method checks if this slice overlaps another one.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#project-instance_method" title="#project (instance method)">- (Array&lt;Slice, Gap&gt;) <strong>project</strong>(coord_system_name) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
The Slice#project method is used to transfer coordinates from one
coordinate system to another.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#protein_align_features-instance_method" title="#protein_align_features (instance method)">- (Array&lt;ProteinAlignFeature&gt;) <strong>protein_align_features</strong>(analysis_name) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Get all ProteinAlignFeatures that are located on a Slice for a given
Analysis.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#repeatmasked_seq-instance_method" title="#repeatmasked_seq (instance method)">- (Object) <strong>repeatmasked_seq</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#split-instance_method" title="#split (instance method)">- (Array&lt;Slice&gt;) <strong>split</strong>(max_size = 100000, overlap = 0) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Creates overlapping subslices for a given Slice.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#sub_slice-instance_method" title="#sub_slice (instance method)">- (Slice) <strong>sub_slice</strong>(start = self.start, stop = self.stop) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Take a sub_slice from an existing one.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#variation_connection-instance_method" title="#variation_connection (instance method)">- (Object) <strong>variation_connection</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#within%3F-instance_method" title="#within? (instance method)">- (Boolean) <strong>within?</strong>(other_slice) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
The Slice#within? method checks if this slice is contained withing another
one.
</p>
</div></span>
  
</li>

      
    </ul>
  

<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <p class="signature first" id="initialize-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span></tt>) <strong>initialize</strong>(seq_region, start = 1, stop = seq_region.length, strand = 1) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Create a new Slice object from scratch.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='chr4 identifier id'>chr4</span> <span class='assign token'>=</span> <span class='SeqRegion constant id'>SeqRegion</span><span class='dot token'>.</span><span class='find_by_name identifier id'>find_by_name</span><span class='lparen token'>(</span><span class='string val'>'4'</span><span class='rparen token'>)</span>
<span class='my_slice identifier id'>my_slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='chr4 identifier id'>chr4</span><span class='comma token'>,</span> <span class='integer val'>95000</span><span class='comma token'>,</span> <span class='integer val'>98000</span><span class='comma token'>,</span> <span class='integer val'>-1</span><span class='rparen token'>)</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt><span class='object_link'><a href="SeqRegion.html" title="Ensembl::Core::SeqRegion (class)">SeqRegion</a></span></tt>)</span>
      
      
        <span class='name'>seq_region</span>
      
      
      
        &mdash;
        <div class='inline'><p>
SeqRegion object
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>start</span>
      
      
        <em class="default">(defaults to: <tt>1</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Start position of the slice on the seq_region
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>stop</span>
      
      
        <em class="default">(defaults to: <tt>seq_region.length</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Stop position of the slice on the seq_region
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>strand</span>
      
      
        <em class="default">(defaults to: <tt>1</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Strand that the slice should be
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


47
48
49
50
51
52
53
54
55
56
57
58
59</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 47</span>

<span class='def def kw'>def</span> <span class='initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='seq_region identifier id'>seq_region</span><span class='comma token'>,</span> <span class='start identifier id'>start</span> <span class='assign token'>=</span> <span class='integer val'>1</span><span class='comma token'>,</span> <span class='stop identifier id'>stop</span> <span class='assign token'>=</span> <span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='length identifier id'>length</span><span class='comma token'>,</span> <span class='strand identifier id'>strand</span> <span class='assign token'>=</span> <span class='integer val'>1</span><span class='rparen token'>)</span>
  <span class='if if kw'>if</span> <span class='start identifier id'>start</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
    <span class='start identifier id'>start</span> <span class='assign token'>=</span> <span class='integer val'>1</span>
  <span class='end end kw'>end</span>
  <span class='if if kw'>if</span> <span class='stop identifier id'>stop</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
    <span class='stop identifier id'>stop</span> <span class='assign token'>=</span> <span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='length identifier id'>length</span>
  <span class='end end kw'>end</span>
  <span class='unless unless kw'>unless</span> <span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='class identifier id'>class</span> <span class='eq op'>==</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='SeqRegion constant id'>SeqRegion</span>
    <span class='raise identifier id'>raise</span> <span class='string val'>'First argument has to be a Ensembl::Core::SeqRegion object'</span>
  <span class='end end kw'>end</span>
  <span class='@seq_region ivar id'>@seq_region</span><span class='comma token'>,</span> <span class='@start ivar id'>@start</span><span class='comma token'>,</span> <span class='@stop ivar id'>@stop</span><span class='comma token'>,</span> <span class='@strand ivar id'>@strand</span> <span class='assign token'>=</span> <span class='seq_region identifier id'>seq_region</span><span class='comma token'>,</span> <span class='start identifier id'>start</span><span class='comma token'>,</span> <span class='stop identifier id'>stop</span><span class='comma token'>,</span> <span class='strand identifier id'>strand</span>
  <span class='@seq ivar id'>@seq</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
  
</div>
<div id="method_missing_details" class="method_details_list">
  <h2>Dynamic Method Handling</h2>
  <p class="notice this">
    This class handles dynamic methods through the <tt>method_missing</tt> method
    
  </p>
  
    <div class="method_details first">
  <p class="signature first" id="method_missing-instance_method">
  
    - (<tt>Object</tt>) <strong>method_missing</strong>(method_name, *args) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
&#8212; As there should be &#8216;getters&#8217; for a lot of classes,
we&#8217;ll implement this with method_missing. For some of the original
methods, see the end of this file.
</p>
<p>
The optional argument is either &#8216;true&#8217; or &#8216;false&#8217;
(default = false). False if the features have to be completely contained
within the slice; true if just a partly overlap is sufficient. ++
Don&#8217;t use this method yourself.
</p>


  </div>
</div>
<div class="tags">
  <h3>Raises:</h3>
<ul class="raise">
  
    <li>
      
        <span class='type'>(<tt>NoMethodError</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 411</span>

<span class='def def kw'>def</span> <span class='method_missing identifier id'>method_missing</span><span class='lparen token'>(</span><span class='method_name identifier id'>method_name</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='args identifier id'>args</span><span class='rparen token'>)</span>
  <span class='table_name identifier id'>table_name</span> <span class='assign token'>=</span> <span class='method_name identifier id'>method_name</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='dot token'>.</span><span class='singularize identifier id'>singularize</span>
  <span class='class_name identifier id'>class_name</span> <span class='assign token'>=</span> <span class='table_name identifier id'>table_name</span><span class='dot token'>.</span><span class='camelcase identifier id'>camelcase</span>

  <span class='comment val'># Convert to the class object</span>
  <span class='target_class identifier id'>target_class</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
  <span class='ObjectSpace constant id'>ObjectSpace</span><span class='dot token'>.</span><span class='each_object identifier id'>each_object</span><span class='lparen token'>(</span><span class='Class constant id'>Class</span><span class='rparen token'>)</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='o identifier id'>o</span><span class='bitor op'>|</span>
    <span class='if if kw'>if</span> <span class='o identifier id'>o</span><span class='dot token'>.</span><span class='name identifier id'>name</span> <span class='match op'>=~</span> <span class='dregexp node'>/^Ensembl::Core::#{class_name}$/</span>
      <span class='target_class identifier id'>target_class</span> <span class='assign token'>=</span> <span class='o identifier id'>o</span>
    <span class='end end kw'>end</span>
  <span class='end end kw'>end</span>

  <span class='comment val'># If it exists, see if it implements Sliceable</span>
  <span class='if if kw'>if</span> <span class='notop op'>!</span> <span class='target_class identifier id'>target_class</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span> <span class='and and kw'>and</span> <span class='target_class identifier id'>target_class</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='Sliceable constant id'>Sliceable</span><span class='rparen token'>)</span>
    <span class='inclusive identifier id'>inclusive</span> <span class='assign token'>=</span> <span class='false false kw'>false</span>
    <span class='if if kw'>if</span> <span class='lbrack token'>[</span><span class='TrueClass constant id'>TrueClass</span><span class='comma token'>,</span> <span class='FalseClass constant id'>FalseClass</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='args identifier id'>args</span><span class='lbrack token'>[</span><span class='integer val'>0</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='class identifier id'>class</span><span class='rparen token'>)</span>
      <span class='inclusive identifier id'>inclusive</span> <span class='assign token'>=</span> <span class='args identifier id'>args</span><span class='lbrack token'>[</span><span class='integer val'>0</span><span class='rbrack token'>]</span>
    <span class='end end kw'>end</span>
    <span class='return return kw'>return</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='get_objects identifier id'>get_objects</span><span class='lparen token'>(</span><span class='target_class identifier id'>target_class</span><span class='comma token'>,</span> <span class='table_name identifier id'>table_name</span><span class='comma token'>,</span> <span class='inclusive identifier id'>inclusive</span><span class='rparen token'>)</span>
  <span class='end end kw'>end</span>

  <span class='raise identifier id'>raise</span> <span class='NoMethodError constant id'>NoMethodError</span>

<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
  
</div>

  <div id="instance_attr_details" class="attr_details">
    <h2>Instance Attribute Details</h2>
    
      
      <span id="seq=-instance_method"></span>
      <span id="seq-instance_method"></span>
      <div class="method_details first">
  <p class="signature first" id="seq-instance_method">
  
    - (<tt>Bio::Sequence::NA</tt>) <strong>seq</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Get the sequence of the Slice as a Bio::Sequence::NA object.
</p>
<p>
If the Slice is on a CoordSystem that is not seq_level, it will try to
project it coordinates to the CoordSystem that does. At this moment, this
is only done if there is a direct link between the two coordinate systems.
(The perl API allows for following an indirect link as well.)
</p>
<p>
Caution: Bio::Sequence::NA makes the sequence downcase!!
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='my_slice identifier id'>my_slice</span><span class='dot token'>.</span><span class='seq identifier id'>seq</span><span class='dot token'>.</span><span class='seq identifier id'>seq</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span>
</pre>
    
  </div>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Bio::Sequence::NA</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Slice sequence as a Bio::Sequence::NA object
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 327</span>

<span class='def def kw'>def</span> <span class='seq identifier id'>seq</span>
  <span class='comment val'># If we already accessed the sequence, we can just</span>
  <span class='comment val'># call the instance variable. Otherwise, we'll have</span>
  <span class='comment val'># to get the sequence first and create a Bio::Sequence::NA</span>
  <span class='comment val'># object.</span>
  <span class='if if kw'>if</span> <span class='@seq ivar id'>@seq</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
    <span class='comment val'># First check if the slice is on the seqlevel coordinate</span>
    <span class='comment val'># system, otherwise project coordinates.</span>
    <span class='if if kw'>if</span> <span class='notop op'>!</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='seqlevel_id identifier id'>seqlevel_id</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span> <span class='and and kw'>and</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system_id identifier id'>coord_system_id</span> <span class='eq op'>==</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='seqlevel_id identifier id'>seqlevel_id</span>
      <span class='@seq ivar id'>@seq</span> <span class='assign token'>=</span> <span class='Bio constant id'>Bio</span><span class='colon2 op'>::</span><span class='Sequence constant id'>Sequence</span><span class='colon2 op'>::</span><span class='NA constant id'>NA</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='subseq identifier id'>subseq</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='comma token'>,</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
    <span class='else else kw'>else</span> <span class='comment val'># we have to project coordinates</span>
      <span class='seq_string identifier id'>seq_string</span> <span class='assign token'>=</span> <span class='String constant id'>String</span><span class='dot token'>.</span><span class='new identifier id'>new</span>
      <span class='@target_slices ivar id'>@target_slices</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='project identifier id'>project</span><span class='lparen token'>(</span><span class='string val'>'seqlevel'</span><span class='rparen token'>)</span>
      <span class='@target_slices ivar id'>@target_slices</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='component identifier id'>component</span><span class='bitor op'>|</span>
        <span class='if if kw'>if</span> <span class='component identifier id'>component</span><span class='dot token'>.</span><span class='class identifier id'>class</span> <span class='eq op'>==</span> <span class='Slice constant id'>Slice</span>
          <span class='seq_string identifier id'>seq_string</span> <span class='opasgn op'>+=</span> <span class='component identifier id'>component</span><span class='dot token'>.</span><span class='seq identifier id'>seq</span> <span class='comment val'># This fetches the seq recursively</span>
        <span class='else else kw'>else</span> <span class='comment val'># it's a Gap</span>
          <span class='seq_string identifier id'>seq_string</span> <span class='opasgn op'>+=</span> <span class='string val'>'N'</span> <span class='mult op'>*</span> <span class='lparen token'>(</span><span class='component identifier id'>component</span><span class='dot token'>.</span><span class='length identifier id'>length</span><span class='rparen token'>)</span>
        <span class='end end kw'>end</span>
      <span class='end end kw'>end</span>
      <span class='@seq ivar id'>@seq</span> <span class='assign token'>=</span> <span class='Bio constant id'>Bio</span><span class='colon2 op'>::</span><span class='Sequence constant id'>Sequence</span><span class='colon2 op'>::</span><span class='NA constant id'>NA</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='seq_string identifier id'>seq_string</span><span class='rparen token'>)</span>

    <span class='end end kw'>end</span>

    <span class='if if kw'>if</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='strand identifier id'>strand</span> <span class='eq op'>==</span> <span class='integer val'>-1</span>
      <span class='@seq ivar id'>@seq</span><span class='dot token'>.</span><span class='reverse_complement! fid id'>reverse_complement!</span>
    <span class='end end kw'>end</span>

  <span class='end end kw'>end</span>
  <span class='return return kw'>return</span> <span class='@seq ivar id'>@seq</span>

<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="seq_region=-instance_method"></span>
      <span id="seq_region-instance_method"></span>
      <div class="method_details ">
  <p class="signature " id="seq_region-instance_method">
  
    - (<tt>Object</tt>) <strong>seq_region</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Returns the value of attribute seq_region
</p>


  </div>
</div>
<div class="tags">
  
</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


30
31
32</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 30</span>

<span class='def def kw'>def</span> <span class='seq_region identifier id'>seq_region</span>
  <span class='@seq_region ivar id'>@seq_region</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="start=-instance_method"></span>
      <span id="start-instance_method"></span>
      <div class="method_details ">
  <p class="signature " id="start-instance_method">
  
    - (<tt>Object</tt>) <strong>start</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Returns the value of attribute start
</p>


  </div>
</div>
<div class="tags">
  
</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


30
31
32</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 30</span>

<span class='def def kw'>def</span> <span class='start identifier id'>start</span>
  <span class='@start ivar id'>@start</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="stop=-instance_method"></span>
      <span id="stop-instance_method"></span>
      <div class="method_details ">
  <p class="signature " id="stop-instance_method">
  
    - (<tt>Object</tt>) <strong>stop</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Returns the value of attribute stop
</p>


  </div>
</div>
<div class="tags">
  
</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


30
31
32</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 30</span>

<span class='def def kw'>def</span> <span class='stop identifier id'>stop</span>
  <span class='@stop ivar id'>@stop</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="strand=-instance_method"></span>
      <span id="strand-instance_method"></span>
      <div class="method_details ">
  <p class="signature " id="strand-instance_method">
  
    - (<tt>Object</tt>) <strong>strand</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Returns the value of attribute strand
</p>


  </div>
</div>
<div class="tags">
  
</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


30
31
32</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 30</span>

<span class='def def kw'>def</span> <span class='strand identifier id'>strand</span>
  <span class='@strand ivar id'>@strand</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>


  <div id="class_method_details" class="method_details_list">
    <h2>Class Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="fetch_all-class_method">
  
    + (<tt>Array&lt;<span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span>&gt;</tt>) <strong>fetch_all</strong>(coord_system_name = 'chromosome', species = Ensembl::SESSION.collection_species, version = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Create an array of all Slices for a given coordinate system.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='slices identifier id'>slices</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_all identifier id'>fetch_all</span><span class='lparen token'>(</span><span class='string val'>'chromosome'</span><span class='rparen token'>)</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>coord_system_name</span>
      
      
        <em class="default">(defaults to: <tt>'chromosome'</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Name of coordinate system
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>species</span>
      
      
        <em class="default">(defaults to: <tt>Ensembl::SESSION.collection_species</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Name of species
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>version</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Version of coordinate system
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span>&gt;</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Array of Slice objects
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 152</span>

<span class='def def kw'>def</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='fetch_all identifier id'>fetch_all</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span> <span class='assign token'>=</span> <span class='string val'>'chromosome'</span><span class='comma token'>,</span><span class='species identifier id'>species</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='collection_species identifier id'>collection_species</span> <span class='comma token'>,</span><span class='version identifier id'>version</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span><span class='rparen token'>)</span>
  <span class='answer identifier id'>answer</span> <span class='assign token'>=</span> <span class='Array constant id'>Array</span><span class='dot token'>.</span><span class='new identifier id'>new</span>
  <span class='coord_system identifier id'>coord_system</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
  <span class='if if kw'>if</span> <span class='Collection constant id'>Collection</span><span class='dot token'>.</span><span class='check identifier id'>check</span>
     <span class='species identifier id'>species</span> <span class='assign token'>=</span> <span class='species identifier id'>species</span><span class='dot token'>.</span><span class='downcase identifier id'>downcase</span>  
     <span class='species_id identifier id'>species_id</span> <span class='assign token'>=</span> <span class='Collection constant id'>Collection</span><span class='dot token'>.</span><span class='get_species_id identifier id'>get_species_id</span><span class='lparen token'>(</span><span class='species identifier id'>species</span><span class='rparen token'>)</span>
     <span class='raise identifier id'>raise</span> <span class='ArgumentError constant id'>ArgumentError</span><span class='comma token'>,</span> <span class='dstring node'>&quot;No specie found in the database with this name: #{species}&quot;</span> <span class='if if_mod kw'>if</span> <span class='species_id identifier id'>species_id</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
     <span class='if if kw'>if</span> <span class='version identifier id'>version</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
        <span class='coord_system identifier id'>coord_system</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='CoordSystem constant id'>CoordSystem</span><span class='dot token'>.</span><span class='find_by_name_and_species_id identifier id'>find_by_name_and_species_id</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='comma token'>,</span><span class='species_id identifier id'>species_id</span><span class='rparen token'>)</span>
     <span class='else else kw'>else</span>
        <span class='coord_system identifier id'>coord_system</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='CoordSystem constant id'>CoordSystem</span><span class='dot token'>.</span><span class='find_by_name_and_species_id_and_version identifier id'>find_by_name_and_species_id_and_version</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='comma token'>,</span> <span class='species_id identifier id'>species_id</span><span class='comma token'>,</span> <span class='version identifier id'>version</span><span class='rparen token'>)</span>
     <span class='end end kw'>end</span>  
  <span class='else else kw'>else</span>
     <span class='if if kw'>if</span> <span class='version identifier id'>version</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
        <span class='coord_system identifier id'>coord_system</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='CoordSystem constant id'>CoordSystem</span><span class='dot token'>.</span><span class='find_by_name identifier id'>find_by_name</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='rparen token'>)</span>
     <span class='else else kw'>else</span>
        <span class='coord_system identifier id'>coord_system</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='CoordSystem constant id'>CoordSystem</span><span class='dot token'>.</span><span class='find_by_name_and_version identifier id'>find_by_name_and_version</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='comma token'>,</span> <span class='version identifier id'>version</span><span class='rparen token'>)</span> 
     <span class='end end kw'>end</span>
  <span class='end end kw'>end</span>
  <span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='seq_regions identifier id'>seq_regions</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='seq_region identifier id'>seq_region</span><span class='bitor op'>|</span>
    <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='seq_region identifier id'>seq_region</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
  <span class='end end kw'>end</span>
  <span class='return return kw'>return</span> <span class='answer identifier id'>answer</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="fetch_by_gene_stable_id-class_method">
  
    + (<tt><span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span></tt>) <strong>fetch_by_gene_stable_id</strong>(gene_stable_id, flanking_seq_length = 0) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Create a Slice based on a Gene
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='my_slice identifier id'>my_slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_gene_stable_id identifier id'>fetch_by_gene_stable_id</span><span class='lparen token'>(</span><span class='string val'>'ENSG00000184895'</span><span class='rparen token'>)</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>gene_stable_id</span>
      
      
      
        &mdash;
        <div class='inline'><p>
Ensembl gene stable ID
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>flanking_seq_length</span>
      
      
        <em class="default">(defaults to: <tt>0</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Length of the flanking sequence
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span></tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Slice object
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


119
120
121
122
123
124
125</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 119</span>

<span class='def def kw'>def</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='fetch_by_gene_stable_id identifier id'>fetch_by_gene_stable_id</span><span class='lparen token'>(</span><span class='gene_stable_id identifier id'>gene_stable_id</span><span class='comma token'>,</span> <span class='flanking_seq_length identifier id'>flanking_seq_length</span> <span class='assign token'>=</span> <span class='integer val'>0</span><span class='rparen token'>)</span>
  <span class='gene_stable_id identifier id'>gene_stable_id</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='GeneStableId constant id'>GeneStableId</span><span class='dot token'>.</span><span class='find_by_stable_id identifier id'>find_by_stable_id</span><span class='lparen token'>(</span><span class='gene_stable_id identifier id'>gene_stable_id</span><span class='rparen token'>)</span>
  <span class='gene identifier id'>gene</span> <span class='assign token'>=</span> <span class='gene_stable_id identifier id'>gene_stable_id</span><span class='dot token'>.</span><span class='gene identifier id'>gene</span>
  <span class='seq_region identifier id'>seq_region</span> <span class='assign token'>=</span> <span class='gene identifier id'>gene</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span>

  <span class='return return kw'>return</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='seq_region identifier id'>seq_region</span><span class='comma token'>,</span> <span class='gene identifier id'>gene</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span> <span class='minus op'>-</span> <span class='flanking_seq_length identifier id'>flanking_seq_length</span><span class='comma token'>,</span> <span class='gene identifier id'>gene</span><span class='dot token'>.</span><span class='seq_region_end identifier id'>seq_region_end</span> <span class='plus op'>+</span> <span class='flanking_seq_length identifier id'>flanking_seq_length</span><span class='comma token'>,</span> <span class='gene identifier id'>gene</span><span class='dot token'>.</span><span class='seq_region_strand identifier id'>seq_region_strand</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="fetch_by_region-class_method">
  
    + (<tt><span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span></tt>) <strong>fetch_by_region</strong>(coord_system_name, seq_region_name, start = nil, stop = nil, strand = 1, species = Ensembl::SESSION.collection_species, version = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Create a Slice without first creating the SeqRegion object.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='my_slice_1 identifier id'>my_slice_1</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='string val'>'chromosome'</span><span class='comma token'>,</span><span class='string val'>'4'</span><span class='comma token'>,</span><span class='integer val'>95000</span><span class='comma token'>,</span><span class='integer val'>98000</span><span class='comma token'>,</span><span class='integer val'>1</span><span class='rparen token'>)</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>coord_system_name</span>
      
      
      
        &mdash;
        <div class='inline'><p>
Name of coordinate system
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>seq_region_name</span>
      
      
      
        &mdash;
        <div class='inline'><p>
name of the seq_region
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>start</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Start position of the slice on the seq_region
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>stop</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Stop position of the slice on the seq_region
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>strand</span>
      
      
        <em class="default">(defaults to: <tt>1</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Strand that the slice should be
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>species</span>
      
      
        <em class="default">(defaults to: <tt>Ensembl::SESSION.collection_species</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Name of species in case of multi-species database
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>version</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Version number of the coordinate system
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span></tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Slice object
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 74</span>

<span class='def def kw'>def</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='comma token'>,</span> <span class='seq_region_name identifier id'>seq_region_name</span><span class='comma token'>,</span> <span class='start identifier id'>start</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span><span class='comma token'>,</span> <span class='stop identifier id'>stop</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span><span class='comma token'>,</span> <span class='strand identifier id'>strand</span> <span class='assign token'>=</span> <span class='integer val'>1</span><span class='comma token'>,</span> <span class='species identifier id'>species</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='collection_species identifier id'>collection_species</span> <span class='comma token'>,</span><span class='version identifier id'>version</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span><span class='rparen token'>)</span>
  <span class='all_coord_systems identifier id'>all_coord_systems</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
  <span class='if if kw'>if</span> <span class='Collection constant id'>Collection</span><span class='dot token'>.</span><span class='check identifier id'>check</span>
    <span class='species identifier id'>species</span> <span class='assign token'>=</span> <span class='species identifier id'>species</span><span class='dot token'>.</span><span class='downcase identifier id'>downcase</span>
    <span class='if if kw'>if</span> <span class='species identifier id'>species</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
      <span class='raise identifier id'>raise</span> <span class='ArgumentError constant id'>ArgumentError</span><span class='comma token'>,</span> <span class='string val'>&quot;When using multi-species db, you must pass a species name to get the correct Slice&quot;</span>
    <span class='else else kw'>else</span>
      <span class='species_id identifier id'>species_id</span> <span class='assign token'>=</span> <span class='Collection constant id'>Collection</span><span class='dot token'>.</span><span class='get_species_id identifier id'>get_species_id</span><span class='lparen token'>(</span><span class='species identifier id'>species</span><span class='rparen token'>)</span>
      <span class='raise identifier id'>raise</span> <span class='ArgumentError constant id'>ArgumentError</span><span class='comma token'>,</span> <span class='dstring node'>&quot;No species found in the database with this name: #{species}&quot;</span> <span class='if if_mod kw'>if</span> <span class='species_id identifier id'>species_id</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span> 
      <span class='all_coord_systems identifier id'>all_coord_systems</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='CoordSystem constant id'>CoordSystem</span><span class='dot token'>.</span><span class='find_all_by_name_and_species_id identifier id'>find_all_by_name_and_species_id</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='comma token'>,</span><span class='species_id identifier id'>species_id</span><span class='rparen token'>)</span>
    <span class='end end kw'>end</span>
  <span class='else else kw'>else</span>
    <span class='all_coord_systems identifier id'>all_coord_systems</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='CoordSystem constant id'>CoordSystem</span><span class='dot token'>.</span><span class='find_all_by_name identifier id'>find_all_by_name</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='rparen token'>)</span>
  <span class='end end kw'>end</span>
  <span class='coord_system identifier id'>coord_system</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
  <span class='if if kw'>if</span> <span class='version identifier id'>version</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span> <span class='comment val'># Take the version with the lower rank</span>
    <span class='coord_system identifier id'>coord_system</span> <span class='assign token'>=</span> <span class='all_coord_systems identifier id'>all_coord_systems</span><span class='dot token'>.</span><span class='sort_by identifier id'>sort_by</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='cs identifier id'>cs</span><span class='bitor op'>|</span> <span class='cs identifier id'>cs</span><span class='dot token'>.</span><span class='rank identifier id'>rank</span><span class='rbrace token'>}</span><span class='dot token'>.</span><span class='shift identifier id'>shift</span>
  <span class='else else kw'>else</span>
    <span class='coord_system identifier id'>coord_system</span> <span class='assign token'>=</span> <span class='all_coord_systems identifier id'>all_coord_systems</span><span class='dot token'>.</span><span class='select identifier id'>select</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='cs identifier id'>cs</span><span class='bitor op'>|</span> <span class='cs identifier id'>cs</span><span class='dot token'>.</span><span class='version identifier id'>version</span> <span class='eq op'>==</span> <span class='version identifier id'>version</span><span class='rbrace token'>}</span><span class='lbrack token'>[</span><span class='integer val'>0</span><span class='rbrack token'>]</span>
  <span class='end end kw'>end</span>
  <span class='unless unless kw'>unless</span> <span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='class identifier id'>class</span> <span class='eq op'>==</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='CoordSystem constant id'>CoordSystem</span>
    <span class='message identifier id'>message</span> <span class='assign token'>=</span> <span class='string val'>&quot;Couldn't find a Ensembl::Core::CoordSystem object with name '&quot;</span> <span class='plus op'>+</span> <span class='coord_system_name identifier id'>coord_system_name</span> <span class='plus op'>+</span> <span class='string val'>&quot;'&quot;</span>
    <span class='if if kw'>if</span> <span class='notop op'>!</span> <span class='version identifier id'>version</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
      <span class='message identifier id'>message</span> <span class='opasgn op'>+=</span> <span class='string val'>&quot; and version '&quot;</span> <span class='plus op'>+</span> <span class='version identifier id'>version</span> <span class='plus op'>+</span> <span class='string val'>&quot;'&quot;</span>
    <span class='end end kw'>end</span>
    <span class='raise identifier id'>raise</span> <span class='message identifier id'>message</span>
  <span class='end end kw'>end</span>

  <span class='seq_region identifier id'>seq_region</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='SeqRegion constant id'>SeqRegion</span><span class='dot token'>.</span><span class='find_by_name_and_coord_system_id identifier id'>find_by_name_and_coord_system_id</span><span class='lparen token'>(</span><span class='seq_region_name identifier id'>seq_region_name</span><span class='comma token'>,</span> <span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='rparen token'>)</span>
  <span class='comment val'>#seq_region = Ensembl::Core::SeqRegion.find_by_sql(&quot;SELECT * FROM seq_region WHERE name = '&quot; + seq_region_name + &quot;' AND coord_system_id = &quot; + coord_system.id.to_s)[0]</span>
  <span class='unless unless kw'>unless</span> <span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='class identifier id'>class</span> <span class='eq op'>==</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='SeqRegion constant id'>SeqRegion</span>
    <span class='raise identifier id'>raise</span> <span class='string val'>&quot;Couldn't find a Ensembl::Core::SeqRegion object with the name '&quot;</span> <span class='plus op'>+</span> <span class='seq_region_name identifier id'>seq_region_name</span> <span class='plus op'>+</span> <span class='string val'>&quot;'&quot;</span>
  <span class='end end kw'>end</span>

  <span class='return return kw'>return</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='seq_region identifier id'>seq_region</span><span class='comma token'>,</span> <span class='start identifier id'>start</span><span class='comma token'>,</span> <span class='stop identifier id'>stop</span><span class='comma token'>,</span> <span class='strand identifier id'>strand</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="fetch_by_transcript_stable_id-class_method">
  
    + (<tt><span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span></tt>) <strong>fetch_by_transcript_stable_id</strong>(transcript_stable_id, flanking_seq_length = 0) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Create a Slice based on a Transcript
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='my_slice identifier id'>my_slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_transcript_stable_id identifier id'>fetch_by_transcript_stable_id</span><span class='lparen token'>(</span><span class='string val'>'ENST00000383673'</span><span class='rparen token'>)</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>transcript_stable_id</span>
      
      
      
        &mdash;
        <div class='inline'><p>
Ensembl transcript stable ID
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>flanking_seq_length</span>
      
      
        <em class="default">(defaults to: <tt>0</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Length of the flanking sequence
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span></tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Slice object
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


135
136
137
138
139
140
141</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 135</span>

<span class='def def kw'>def</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='fetch_by_transcript_stable_id identifier id'>fetch_by_transcript_stable_id</span><span class='lparen token'>(</span><span class='transcript_stable_id identifier id'>transcript_stable_id</span><span class='comma token'>,</span> <span class='flanking_seq_length identifier id'>flanking_seq_length</span> <span class='assign token'>=</span> <span class='integer val'>0</span><span class='rparen token'>)</span>
  <span class='transcript_stable_id identifier id'>transcript_stable_id</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='TranscriptStableId constant id'>TranscriptStableId</span><span class='dot token'>.</span><span class='find_by_stable_id identifier id'>find_by_stable_id</span><span class='lparen token'>(</span><span class='transcript_stable_id identifier id'>transcript_stable_id</span><span class='rparen token'>)</span>
  <span class='transcript identifier id'>transcript</span> <span class='assign token'>=</span> <span class='transcript_stable_id identifier id'>transcript_stable_id</span><span class='dot token'>.</span><span class='transcript identifier id'>transcript</span>
  <span class='seq_region identifier id'>seq_region</span> <span class='assign token'>=</span> <span class='transcript identifier id'>transcript</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span>

  <span class='return return kw'>return</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='seq_region identifier id'>seq_region</span><span class='comma token'>,</span> <span class='transcript identifier id'>transcript</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span> <span class='minus op'>-</span> <span class='flanking_seq_length identifier id'>flanking_seq_length</span><span class='comma token'>,</span> <span class='transcript identifier id'>transcript</span><span class='dot token'>.</span><span class='seq_region_end identifier id'>seq_region_end</span> <span class='plus op'>+</span> <span class='flanking_seq_length identifier id'>flanking_seq_length</span><span class='comma token'>,</span> <span class='transcript identifier id'>transcript</span><span class='dot token'>.</span><span class='seq_region_strand identifier id'>seq_region_strand</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="display_name-instance_method">
  
    - (<tt>String</tt>) <strong>display_name</strong> 
  

  
    <span class="aliases">Also known as:
    <span class="names"><span id='to_s-instance_method'>to_s</span></span>
    </span>
  
</p><div class="docstring">
  <div class="discussion">
    <p>
The display_name method returns a full name of this slice, containing the
name of the coordinate system, the sequence region, start and stop
positions on that sequence region and the strand. E.g. for a slice of
bovine chromosome 4 from position 95000 to 98000 on the reverse strand, the
display_name would look like: chromosome:4:Btau_3.1:95000:98000:-1
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='puts identifier id'>puts</span> <span class='my_slice identifier id'>my_slice</span><span class='dot token'>.</span><span class='display_name identifier id'>display_name</span>
</pre>
    
  </div>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Nicely formatted name of the Slice
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


203
204
205</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 203</span>

<span class='def def kw'>def</span> <span class='display_name identifier id'>display_name</span>
  <span class='return return kw'>return</span> <span class='lbrack token'>[</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='comma token'>,</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='version identifier id'>version</span><span class='comma token'>,</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='comma token'>,</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='comma token'>,</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='comma token'>,</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='strand identifier id'>strand</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='string val'>':'</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="dna_align_features-instance_method">
  
    - (<tt>Array&lt;<span class='object_link'><a href="DnaAlignFeature.html" title="Ensembl::Core::DnaAlignFeature (class)">DnaAlignFeature</a></span>&gt;</tt>) <strong>dna_align_features</strong>(analysis_name = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Get all DnaAlignFeatures that are located on a Slice for a given Analysis.
</p>
<p>
Pitfall: just looks at the CoordSystem that the Slice is located on. For
example, if a Slice is located on a SeqRegion on the
&#8216;chromosome&#8217; CoordSystem, but all dna_align_features are
annotated on SeqRegions of the &#8216;scaffold&#8217; CoordSystem, this
method will return an empty array.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='my_slice identifier id'>my_slice</span><span class='dot token'>.</span><span class='dna_align_features identifier id'>dna_align_features</span><span class='lparen token'>(</span><span class='string val'>'Vertrna'</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='feature identifier id'>feature</span><span class='bitor op'>|</span>
  <span class='puts identifier id'>puts</span> <span class='feature identifier id'>feature</span><span class='dot token'>.</span><span class='to_yaml identifier id'>to_yaml</span>
<span class='end end kw'>end</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>analysis_name</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Name of analysis
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="DnaAlignFeature.html" title="Ensembl::Core::DnaAlignFeature (class)">DnaAlignFeature</a></span>&gt;</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Array of DnaAlignFeature objects
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


561
562
563
564
565
566
567
568</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 561</span>

<span class='def def kw'>def</span> <span class='dna_align_features identifier id'>dna_align_features</span><span class='lparen token'>(</span><span class='analysis_name identifier id'>analysis_name</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span><span class='rparen token'>)</span>
  <span class='if if kw'>if</span> <span class='analysis_name identifier id'>analysis_name</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
    <span class='return return kw'>return</span> <span class='DnaAlignFeature constant id'>DnaAlignFeature</span><span class='dot token'>.</span><span class='find_by_sql identifier id'>find_by_sql</span><span class='lparen token'>(</span><span class='string val'>'SELECT * FROM dna_align_feature WHERE seq_region_id = '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='plus op'>+</span> <span class='string val'>' AND seq_region_start &gt;= '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='plus op'>+</span> <span class='string val'>' AND seq_region_end &lt;= '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='rparen token'>)</span>
  <span class='else else kw'>else</span>
    <span class='analysis identifier id'>analysis</span> <span class='assign token'>=</span> <span class='Analysis constant id'>Analysis</span><span class='dot token'>.</span><span class='find_by_logic_name identifier id'>find_by_logic_name</span><span class='lparen token'>(</span><span class='analysis_name identifier id'>analysis_name</span><span class='rparen token'>)</span>
    <span class='return return kw'>return</span> <span class='DnaAlignFeature constant id'>DnaAlignFeature</span><span class='dot token'>.</span><span class='find_by_sql identifier id'>find_by_sql</span><span class='lparen token'>(</span><span class='string val'>'SELECT * FROM dna_align_feature WHERE seq_region_id = '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='plus op'>+</span> <span class='string val'>' AND seq_region_start &gt;= '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='plus op'>+</span> <span class='string val'>' AND seq_region_end &lt;= '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='plus op'>+</span> <span class='string val'>' AND analysis_id = '</span> <span class='plus op'>+</span> <span class='analysis identifier id'>analysis</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='rparen token'>)</span>
  <span class='end end kw'>end</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="excise-instance_method">
  
    - (<tt>Array&lt;<span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span>&gt;</tt>) <strong>excise</strong>(ranges) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
The Slice#excise method removes a bit of a slice and returns the remainder
as separate slices.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='original_slice identifier id'>original_slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='string val'>'chromosome'</span><span class='comma token'>,</span><span class='string val'>'X'</span><span class='comma token'>,</span><span class='integer val'>1</span><span class='comma token'>,</span><span class='integer val'>10000</span><span class='rparen token'>)</span>
<span class='new_slices identifier id'>new_slices</span> <span class='assign token'>=</span> <span class='original_slice identifier id'>original_slice</span><span class='dot token'>.</span><span class='excise identifier id'>excise</span><span class='lparen token'>(</span><span class='lbrack token'>[</span><span class='float val'>500</span><span class='dot2 op'>..</span><span class='integer val'>750</span><span class='comma token'>,</span> <span class='float val'>1050</span><span class='dot2 op'>..</span><span class='integer val'>1075</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
<span class='new_slices identifier id'>new_slices</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='s identifier id'>s</span><span class='bitor op'>|</span>
  <span class='puts identifier id'>puts</span> <span class='s identifier id'>s</span><span class='dot token'>.</span><span class='display_name identifier id'>display_name</span>
<span class='end end kw'>end</span>

<span class='comment val'># result:</span>
<span class='comment val'>#   chromosome:X:1:499:1</span>
<span class='comment val'>#   chromosome:X:751:1049:1</span>
<span class='comment val'>#   chromosome:X:1076:10000:1</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;Range&gt;</tt>)</span>
      
      
        <span class='name'>Array</span>
      
      
      
        &mdash;
        <div class='inline'><p>
of ranges to excise
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span>&gt;</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Array of slices
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 285</span>

<span class='def def kw'>def</span> <span class='excise identifier id'>excise</span><span class='lparen token'>(</span><span class='ranges identifier id'>ranges</span><span class='rparen token'>)</span>
  <span class='if if kw'>if</span> <span class='ranges identifier id'>ranges</span><span class='dot token'>.</span><span class='class identifier id'>class</span> <span class='neq op'>!=</span> <span class='Array constant id'>Array</span>
    <span class='raise identifier id'>raise</span> <span class='RuntimeError constant id'>RuntimeError</span><span class='comma token'>,</span> <span class='string val'>&quot;Argument should be an array of ranges&quot;</span>
  <span class='end end kw'>end</span>
  <span class='ranges identifier id'>ranges</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='r identifier id'>r</span><span class='bitor op'>|</span>
    <span class='if if kw'>if</span> <span class='r identifier id'>r</span><span class='dot token'>.</span><span class='class identifier id'>class</span> <span class='neq op'>!=</span> <span class='Range constant id'>Range</span>
      <span class='raise identifier id'>raise</span> <span class='RuntimeError constant id'>RuntimeError</span><span class='comma token'>,</span> <span class='string val'>&quot;Argument should be an array of ranges&quot;</span>
    <span class='end end kw'>end</span>
  <span class='end end kw'>end</span>

  <span class='answer identifier id'>answer</span> <span class='assign token'>=</span> <span class='Array constant id'>Array</span><span class='dot token'>.</span><span class='new identifier id'>new</span>
  <span class='previous_excised_stop identifier id'>previous_excised_stop</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='minus op'>-</span> <span class='integer val'>1</span>
  <span class='ranges identifier id'>ranges</span><span class='dot token'>.</span><span class='sort_by identifier id'>sort_by</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='r identifier id'>r</span><span class='bitor op'>|</span> <span class='r identifier id'>r</span><span class='dot token'>.</span><span class='first identifier id'>first</span><span class='rbrace token'>}</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='r identifier id'>r</span><span class='bitor op'>|</span>
    <span class='subslice_start identifier id'>subslice_start</span> <span class='assign token'>=</span> <span class='previous_excised_stop identifier id'>previous_excised_stop</span> <span class='plus op'>+</span> <span class='integer val'>1</span>
    <span class='if if kw'>if</span> <span class='subslice_start identifier id'>subslice_start</span> <span class='leq op'>&lt;=</span> <span class='r identifier id'>r</span><span class='dot token'>.</span><span class='first identifier id'>first</span> <span class='minus op'>-</span> <span class='integer val'>1</span>
      <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='comma token'>,</span> <span class='subslice_start identifier id'>subslice_start</span><span class='comma token'>,</span> <span class='r identifier id'>r</span><span class='dot token'>.</span><span class='first identifier id'>first</span> <span class='minus op'>-</span> <span class='integer val'>1</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
    <span class='end end kw'>end</span>
    <span class='previous_excised_stop identifier id'>previous_excised_stop</span> <span class='assign token'>=</span> <span class='r identifier id'>r</span><span class='dot token'>.</span><span class='last identifier id'>last</span>
    <span class='if if kw'>if</span> <span class='r identifier id'>r</span><span class='dot token'>.</span><span class='last identifier id'>last</span> <span class='gt op'>&gt;</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span>
      <span class='return return kw'>return</span> <span class='answer identifier id'>answer</span>
    <span class='end end kw'>end</span>
  <span class='end end kw'>end</span>
  <span class='subslice_start identifier id'>subslice_start</span> <span class='assign token'>=</span> <span class='previous_excised_stop identifier id'>previous_excised_stop</span> <span class='plus op'>+</span> <span class='integer val'>1</span>
  <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='comma token'>,</span> <span class='subslice_start identifier id'>subslice_start</span><span class='comma token'>,</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
  <span class='return return kw'>return</span> <span class='answer identifier id'>answer</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_genotyped_variation_features-instance_method">
  
    - (<tt>Object</tt>) <strong>get_genotyped_variation_features</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


611
612
613
614</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 611</span>

<span class='def def kw'>def</span> <span class='get_genotyped_variation_features identifier id'>get_genotyped_variation_features</span>
  <span class='variation_connection identifier id'>variation_connection</span><span class='lparen token'>(</span><span class='rparen token'>)</span>
  <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Variation constant id'>Variation</span><span class='colon2 op'>::</span><span class='VariationFeature constant id'>VariationFeature</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='symbol val'>:all</span><span class='comma token'>,</span><span class='symbol val'>:conditions</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='string val'>&quot;flags = 'genotyped' AND seq_region_id = ? AND seq_region_start &gt;= ? AND seq_region_end &lt;= ?&quot;</span><span class='comma token'>,</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='seq_region_id identifier id'>seq_region_id</span><span class='comma token'>,</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='comma token'>,</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_objects-instance_method">
  
    - (<tt>Object</tt>) <strong>get_objects</strong>(target_class, table_name, inclusive = false) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Don&#8217;t use this method yourself.
</p>


  </div>
</div>
<div class="tags">
  
</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 437</span>

<span class='def def kw'>def</span> <span class='get_objects identifier id'>get_objects</span><span class='lparen token'>(</span><span class='target_class identifier id'>target_class</span><span class='comma token'>,</span> <span class='table_name identifier id'>table_name</span><span class='comma token'>,</span> <span class='inclusive identifier id'>inclusive</span> <span class='assign token'>=</span> <span class='false false kw'>false</span><span class='rparen token'>)</span>
  <span class='answer identifier id'>answer</span> <span class='assign token'>=</span> <span class='Array constant id'>Array</span><span class='dot token'>.</span><span class='new identifier id'>new</span>

  <span class='coord_system_ids_with_features identifier id'>coord_system_ids_with_features</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
  <span class='comment val'># Get all the coord_systems with this type of features on them</span>
  <span class='if if kw'>if</span> <span class='Collection constant id'>Collection</span><span class='dot token'>.</span><span class='check identifier id'>check</span>
    <span class='coord_system_ids_with_features identifier id'>coord_system_ids_with_features</span> <span class='assign token'>=</span> <span class='Collection constant id'>Collection</span><span class='dot token'>.</span><span class='find_all_coord_by_table_name identifier id'>find_all_coord_by_table_name</span><span class='lparen token'>(</span><span class='table_name identifier id'>table_name</span><span class='comma token'>,</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='species_id identifier id'>species_id</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='collect identifier id'>collect</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='mc identifier id'>mc</span><span class='bitor op'>|</span> <span class='mc identifier id'>mc</span><span class='dot token'>.</span><span class='coord_system_id identifier id'>coord_system_id</span><span class='rbrace token'>}</span>
  <span class='else else kw'>else</span>
    <span class='coord_system_ids_with_features identifier id'>coord_system_ids_with_features</span> <span class='assign token'>=</span> <span class='MetaCoord constant id'>MetaCoord</span><span class='dot token'>.</span><span class='find_all_by_table_name identifier id'>find_all_by_table_name</span><span class='lparen token'>(</span><span class='table_name identifier id'>table_name</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='collect identifier id'>collect</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='mc identifier id'>mc</span><span class='bitor op'>|</span> <span class='mc identifier id'>mc</span><span class='dot token'>.</span><span class='coord_system_id identifier id'>coord_system_id</span><span class='rbrace token'>}</span>
  <span class='end end kw'>end</span>  
  <span class='comment val'># Get the features of the original slice</span>
  <span class='if if kw'>if</span> <span class='coord_system_ids_with_features identifier id'>coord_system_ids_with_features</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system_id identifier id'>coord_system_id</span><span class='rparen token'>)</span>
    <span class='sql identifier id'>sql</span> <span class='assign token'>=</span> <span class='string val'>''</span>
    <span class='if if kw'>if</span> <span class='inclusive identifier id'>inclusive</span>
      <span class='sql identifier id'>sql</span> <span class='assign token'>=</span> <span class='string val'>&quot;SELECT * FROM \#{table_name}\nWHERE seq_region_id = \#{self.seq_region.id.to_s}\nAND (( seq_region_start BETWEEN \#{self.start.to_s} AND \#{self.stop.to_s} )\nOR   ( seq_region_end BETWEEN \#{self.start.to_s} AND \#{self.stop.to_s} )\nOR   ( seq_region_start &lt;= \#{self.start.to_s} AND seq_region_end &gt;= \#{self.stop.to_s} )\n    )\n&quot;</span>
    <span class='else else kw'>else</span>
      <span class='sql identifier id'>sql</span> <span class='assign token'>=</span> <span class='string val'>&quot;SELECT * FROM \#{table_name}\nWHERE seq_region_id = \#{self.seq_region.id.to_s}\nAND seq_region_start &gt;= \#{self.start.to_s}\nAND seq_region_end &lt;= \#{self.stop.to_s}   \n&quot;</span>
    <span class='end end kw'>end</span>
    <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='target_class identifier id'>target_class</span><span class='dot token'>.</span><span class='find_by_sql identifier id'>find_by_sql</span><span class='lparen token'>(</span><span class='sql identifier id'>sql</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
    <span class='coord_system_ids_with_features identifier id'>coord_system_ids_with_features</span><span class='dot token'>.</span><span class='delete identifier id'>delete</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system_id identifier id'>coord_system_id</span><span class='rparen token'>)</span>
  <span class='end end kw'>end</span>

  <span class='comment val'># Transform the original slice to other coord systems and get those</span>
  <span class='comment val'># features as well. At the moment, only 'direct' projections can be made.</span>
  <span class='comment val'># Later, I'm hoping to add functionality for following a path from one</span>
  <span class='comment val'># coord_system to another if they're not directly linked in the assembly</span>
  <span class='comment val'># table.</span>
  <span class='coord_system_ids_with_features identifier id'>coord_system_ids_with_features</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='target_coord_system_id identifier id'>target_coord_system_id</span><span class='bitor op'>|</span>
    <span class='target_slices identifier id'>target_slices</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='project identifier id'>project</span><span class='lparen token'>(</span><span class='CoordSystem constant id'>CoordSystem</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='target_coord_system_id identifier id'>target_coord_system_id</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='rparen token'>)</span>
    <span class='target_slices identifier id'>target_slices</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='slice identifier id'>slice</span><span class='bitor op'>|</span>
      <span class='if if kw'>if</span> <span class='slice identifier id'>slice</span><span class='dot token'>.</span><span class='class identifier id'>class</span> <span class='eq op'>==</span> <span class='Slice constant id'>Slice</span>
        <span class='if if kw'>if</span> <span class='inclusive identifier id'>inclusive</span>
          <span class='sql identifier id'>sql</span> <span class='assign token'>=</span> <span class='string val'>&quot;SELECT * FROM \#{table_name}\nWHERE seq_region_id = \#{slice.seq_region.id.to_s}\nAND (( seq_region_start BETWEEN \#{slice.start.to_s} AND \#{slice.stop.to_s} )\nOR   ( seq_region_end BETWEEN \#{slice.start.to_s} AND \#{slice.stop.to_s} )\nOR   ( seq_region_start &lt;= \#{slice.start.to_s} AND seq_region_end &gt;= \#{slice.stop.to_s} )\n    )\n&quot;</span>
        <span class='else else kw'>else</span>
          <span class='sql identifier id'>sql</span> <span class='assign token'>=</span> <span class='string val'>&quot;SELECT * FROM \#{table_name}\nWHERE seq_region_id = \#{slice.seq_region.id.to_s}\nAND seq_region_start &gt;= \#{slice.start.to_s}\nAND seq_region_end &lt;= \#{slice.stop.to_s}   \n&quot;</span>
        <span class='end end kw'>end</span> 
          <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='target_class identifier id'>target_class</span><span class='dot token'>.</span><span class='find_by_sql identifier id'>find_by_sql</span><span class='lparen token'>(</span><span class='sql identifier id'>sql</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
      <span class='end end kw'>end</span>
    <span class='end end kw'>end</span>
  <span class='end end kw'>end</span>

  <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='flatten! fid id'>flatten!</span>
  <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='uniq! fid id'>uniq!</span>

  <span class='return return kw'>return</span> <span class='answer identifier id'>answer</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_structural_variations-instance_method">
  
    - (<tt>Object</tt>) <strong>get_structural_variations</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


616
617
618
619</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 616</span>

<span class='def def kw'>def</span> <span class='get_structural_variations identifier id'>get_structural_variations</span>
  <span class='variation_connection identifier id'>variation_connection</span><span class='lparen token'>(</span><span class='rparen token'>)</span>
  <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Variation constant id'>Variation</span><span class='colon2 op'>::</span><span class='StructuralVariation constant id'>StructuralVariation</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='symbol val'>:all</span><span class='comma token'>,</span><span class='symbol val'>:conditions</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='string val'>&quot;seq_region_id = ? AND seq_region_start &gt;= ? AND seq_region_end &lt;= ?&quot;</span><span class='comma token'>,</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='seq_region_id identifier id'>seq_region_id</span><span class='comma token'>,</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='comma token'>,</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_variation_features-instance_method">
  
    - (<tt>Object</tt>) <strong>get_variation_features</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Method to retrieve Variation features from Ensembl::Core::Slice objects
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='slice identifier id'>slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='string val'>'chromosome'</span><span class='comma token'>,</span><span class='integer val'>1</span><span class='comma token'>,</span><span class='integer val'>50000</span><span class='comma token'>,</span><span class='integer val'>51000</span><span class='rparen token'>)</span>
<span class='variations identifier id'>variations</span> <span class='assign token'>=</span> <span class='slice identifier id'>slice</span><span class='dot token'>.</span><span class='get_variation_features identifier id'>get_variation_features</span>
<span class='variations identifier id'>variations</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='vf identifier id'>vf</span><span class='bitor op'>|</span>
 <span class='puts identifier id'>puts</span> <span class='vf identifier id'>vf</span><span class='dot token'>.</span><span class='variation_name identifier id'>variation_name</span><span class='comma token'>,</span> <span class='vf identifier id'>vf</span><span class='dot token'>.</span><span class='allele_string identifier id'>allele_string</span>
 <span class='puts identifier id'>puts</span> <span class='vf identifier id'>vf</span><span class='dot token'>.</span><span class='variation identifier id'>variation</span><span class='dot token'>.</span><span class='ancestral_allele identifier id'>ancestral_allele</span>
<span class='end end kw'>end</span>
</pre>
    
  </div>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


606
607
608
609</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 606</span>

<span class='def def kw'>def</span> <span class='get_variation_features identifier id'>get_variation_features</span>
  <span class='variation_connection identifier id'>variation_connection</span><span class='lparen token'>(</span><span class='rparen token'>)</span>
  <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Variation constant id'>Variation</span><span class='colon2 op'>::</span><span class='VariationFeature constant id'>VariationFeature</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='symbol val'>:all</span><span class='comma token'>,</span><span class='symbol val'>:conditions</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='string val'>&quot;seq_region_id = ? AND seq_region_start &gt;= ? AND seq_region_end &lt;= ?&quot;</span><span class='comma token'>,</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='seq_region_id identifier id'>seq_region_id</span><span class='comma token'>,</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='comma token'>,</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="length-instance_method">
  
    - (<tt>Integer</tt>) <strong>length</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Get the length of a slice
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='chr4 identifier id'>chr4</span> <span class='assign token'>=</span> <span class='SeqRegion constant id'>SeqRegion</span><span class='dot token'>.</span><span class='find_by_name identifier id'>find_by_name</span><span class='lparen token'>(</span><span class='string val'>'4'</span><span class='rparen token'>)</span>
<span class='my_slice identifier id'>my_slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='chr4 identifier id'>chr4</span><span class='comma token'>,</span> <span class='integer val'>95000</span><span class='comma token'>,</span> <span class='integer val'>98000</span><span class='comma token'>,</span> <span class='integer val'>-1</span><span class='rparen token'>)</span>
<span class='puts identifier id'>puts</span> <span class='my_slice identifier id'>my_slice</span><span class='dot token'>.</span><span class='length identifier id'>length</span>
</pre>
    
  </div>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Length of the slice
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


189
190
191</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 189</span>

<span class='def def kw'>def</span> <span class='length identifier id'>length</span>
  <span class='return return kw'>return</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='minus op'>-</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='plus op'>+</span> <span class='integer val'>1</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="misc_features-instance_method">
  
    - (<tt>Array&lt;<span class='object_link'><a href="MiscFeature.html" title="Ensembl::Core::MiscFeature (class)">MiscFeature</a></span>&gt;</tt>) <strong>misc_features</strong>(code) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Get all MiscFeatures that are located on a Slice for a given MiscSet.
</p>
<p>
Pitfall: just looks at the CoordSystem that the Slice is located on. For
example, if a Slice is located on a SeqRegion on the
&#8216;chromosome&#8217; CoordSystem, but all misc_features are annotated
on SeqRegions of the &#8216;scaffold&#8217; CoordSystem, this method will
return an empty array.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='my_slice identifier id'>my_slice</span><span class='dot token'>.</span><span class='misc_features identifier id'>misc_features</span><span class='lparen token'>(</span><span class='string val'>'encode'</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='feature identifier id'>feature</span><span class='bitor op'>|</span>
  <span class='puts identifier id'>puts</span> <span class='feature identifier id'>feature</span><span class='dot token'>.</span><span class='to_yaml identifier id'>to_yaml</span>
<span class='end end kw'>end</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>code</span>
      
      
      
        &mdash;
        <div class='inline'><p>
Code of MiscSet
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="MiscFeature.html" title="Ensembl::Core::MiscFeature (class)">MiscFeature</a></span>&gt;</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Array of MiscFeature objects
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 527</span>

<span class='def def kw'>def</span> <span class='misc_features identifier id'>misc_features</span><span class='lparen token'>(</span><span class='code identifier id'>code</span><span class='rparen token'>)</span>
  <span class='answer identifier id'>answer</span> <span class='assign token'>=</span> <span class='Array constant id'>Array</span><span class='dot token'>.</span><span class='new identifier id'>new</span>
  <span class='if if kw'>if</span> <span class='code identifier id'>code</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
    <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='misc_features identifier id'>misc_features</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='mf identifier id'>mf</span><span class='bitor op'>|</span>
      <span class='if if kw'>if</span> <span class='mf identifier id'>mf</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span> <span class='gt op'>&gt;</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='and and kw'>and</span> <span class='mf identifier id'>mf</span><span class='dot token'>.</span><span class='seq_region_end identifier id'>seq_region_end</span> <span class='lt op'>&lt;</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span>
        <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='mf identifier id'>mf</span><span class='rparen token'>)</span>
      <span class='end end kw'>end</span>
    <span class='end end kw'>end</span>
  <span class='else else kw'>else</span>
    <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='misc_features identifier id'>misc_features</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='mf identifier id'>mf</span><span class='bitor op'>|</span>
      <span class='if if kw'>if</span> <span class='mf identifier id'>mf</span><span class='dot token'>.</span><span class='misc_sets identifier id'>misc_sets</span><span class='lbrack token'>[</span><span class='integer val'>0</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='code identifier id'>code</span> <span class='eq op'>==</span> <span class='code identifier id'>code</span>
        <span class='if if kw'>if</span> <span class='mf identifier id'>mf</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span> <span class='gt op'>&gt;</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='and and kw'>and</span> <span class='mf identifier id'>mf</span><span class='dot token'>.</span><span class='seq_region_end identifier id'>seq_region_end</span> <span class='lt op'>&lt;</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span>
          <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='mf identifier id'>mf</span><span class='rparen token'>)</span>
        <span class='end end kw'>end</span>
      <span class='end end kw'>end</span>
    <span class='end end kw'>end</span>
  <span class='end end kw'>end</span>
  <span class='return return kw'>return</span> <span class='answer identifier id'>answer</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="overlaps?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>overlaps?</strong>(other_slice) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
The Slice#overlaps? method checks if this slice overlaps another one. The
other slice has to be on the same coordinate system
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='slice_a identifier id'>slice_a</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='string val'>'chromosome'</span><span class='comma token'>,</span><span class='string val'>'X'</span><span class='comma token'>,</span><span class='integer val'>1</span><span class='comma token'>,</span><span class='integer val'>1000</span><span class='rparen token'>)</span>
<span class='slice_b identifier id'>slice_b</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='string val'>'chromosome'</span><span class='comma token'>,</span><span class='string val'>'X'</span><span class='comma token'>,</span><span class='integer val'>900</span><span class='comma token'>,</span><span class='integer val'>1500</span><span class='rparen token'>)</span>
<span class='if if kw'>if</span> <span class='slice_a identifier id'>slice_a</span><span class='dot token'>.</span><span class='overlaps? fid id'>overlaps?</span><span class='lparen token'>(</span><span class='slice_b identifier id'>slice_b</span><span class='rparen token'>)</span>
  <span class='puts identifier id'>puts</span> <span class='string val'>&quot;There slices overlap&quot;</span>
<span class='end end kw'>end</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span></tt>)</span>
      
      
        <span class='name'>other_slice</span>
      
      
      
        &mdash;
        <div class='inline'><p>
Another slice
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
True if slices overlap, otherwise false
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 220</span>

<span class='def def kw'>def</span> <span class='overlaps? fid id'>overlaps?</span><span class='lparen token'>(</span><span class='other_slice identifier id'>other_slice</span><span class='rparen token'>)</span>
  <span class='if if kw'>if</span> <span class='notop op'>!</span> <span class='other_slice identifier id'>other_slice</span><span class='dot token'>.</span><span class='class identifier id'>class</span> <span class='eq op'>==</span> <span class='Slice constant id'>Slice</span>
    <span class='raise identifier id'>raise</span> <span class='RuntimeError constant id'>RuntimeError</span><span class='comma token'>,</span> <span class='string val'>&quot;The Slice#overlaps? method takes a Slice object as its arguments.&quot;</span>
  <span class='end end kw'>end</span>
  <span class='if if kw'>if</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span> <span class='neq op'>!=</span> <span class='other_slice identifier id'>other_slice</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span>
    <span class='raise identifier id'>raise</span> <span class='RuntimeError constant id'>RuntimeError</span><span class='comma token'>,</span> <span class='string val'>&quot;The argument slice of Slice#overlaps? has to be in the same coordinate system, but were &quot;</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='name identifier id'>name</span> <span class='plus op'>+</span> <span class='string val'>&quot; and &quot;</span> <span class='plus op'>+</span> <span class='other_slice identifier id'>other_slice</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='name identifier id'>name</span>
  <span class='end end kw'>end</span>

  <span class='self_range identifier id'>self_range</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='dot2 op'>..</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span>
  <span class='other_range identifier id'>other_range</span> <span class='assign token'>=</span> <span class='other_slice identifier id'>other_slice</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='dot2 op'>..</span> <span class='other_slice identifier id'>other_slice</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span>

  <span class='if if kw'>if</span> <span class='self_range identifier id'>self_range</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='other_slice identifier id'>other_slice</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='rparen token'>)</span> <span class='or or kw'>or</span> <span class='other_range identifier id'>other_range</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='rparen token'>)</span>
    <span class='return return kw'>return</span> <span class='true true kw'>true</span>
  <span class='else else kw'>else</span>
    <span class='return return kw'>return</span> <span class='false false kw'>false</span>
  <span class='end end kw'>end</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="project-instance_method">
  
    - (<tt>Array&lt;<span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span>, <span class='object_link'><a href="Gap.html" title="Ensembl::Core::Gap (class)">Gap</a></span>&gt;</tt>) <strong>project</strong>(coord_system_name) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
The Slice#project method is used to transfer coordinates from one
coordinate system to another. Suppose you have a slice on a contig in human
(let&#8217;s say on contig AC000031.6.1.38703) and you want to know the
coordinates on the chromosome. This is a projection of coordinates from a
higher ranked coordinate system to a lower ranked coordinate system.
Projections can also be done from a chromosome to the contig level.
However, it might be possible that more than one contig has to be included
and that there exist gaps between the contigs. The output of this method
therefore is an <em>array</em> of Slice and Gap objects.
</p>
<p>
At the moment, projections can only be done if the two coordinate systems
are linked directly in the &#8216;assembly&#8217; table.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='comment val'># Get a contig slice in cow and project to scaffold level</span>
<span class='comment val'># (i.e. going from a high rank coord system to a lower rank coord</span>
<span class='comment val'># system)</span>
<span class='source_slice identifier id'>source_slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='string val'>'contig'</span><span class='comma token'>,</span> <span class='string val'>'AAFC03020247'</span><span class='comma token'>,</span> <span class='integer val'>42</span><span class='comma token'>,</span> <span class='integer val'>2007</span><span class='rparen token'>)</span>
<span class='target_slices identifier id'>target_slices</span> <span class='assign token'>=</span> <span class='source_slice identifier id'>source_slice</span><span class='dot token'>.</span><span class='project identifier id'>project</span><span class='lparen token'>(</span><span class='string val'>'scaffold'</span><span class='rparen token'>)</span>
<span class='puts identifier id'>puts</span> <span class='target_slices identifier id'>target_slices</span><span class='dot token'>.</span><span class='length identifier id'>length</span>      <span class='comment val'>#--&gt; 1</span>
<span class='puts identifier id'>puts</span> <span class='target_slices identifier id'>target_slices</span><span class='lbrack token'>[</span><span class='integer val'>0</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='display_name identifier id'>display_name</span> <span class='comment val'>#--&gt; scaffold:ChrUn.003.3522:6570:8535:1</span>

<span class='comment val'># Get a chromosome slice in cow and project to scaffold level</span>
<span class='comment val'># (i.e. going from a low rank coord system to a higher rank coord</span>
<span class='comment val'># system)</span>
<span class='comment val'># The region 96652152..98000000 on BTA4 is covered by 2 scaffolds</span>
<span class='comment val'># that are separated by a gap.</span>
<span class='source_slice identifier id'>source_slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='string val'>'chromosome'</span><span class='comma token'>,</span><span class='string val'>'4'</span><span class='comma token'>,</span> <span class='integer val'>96652152</span><span class='comma token'>,</span> <span class='integer val'>98000000</span><span class='rparen token'>)</span>
<span class='target_slices identifier id'>target_slices</span> <span class='assign token'>=</span> <span class='source_slice identifier id'>source_slice</span><span class='dot token'>.</span><span class='project identifier id'>project</span><span class='lparen token'>(</span><span class='string val'>'scaffold'</span><span class='rparen token'>)</span>
<span class='puts identifier id'>puts</span> <span class='target_slices identifier id'>target_slices</span><span class='dot token'>.</span><span class='length identifier id'>length</span>      <span class='comment val'>#--&gt; 3</span>
<span class='first_bit identifier id'>first_bit</span><span class='comma token'>,</span> <span class='second_bit identifier id'>second_bit</span><span class='comma token'>,</span> <span class='third_bit identifier id'>third_bit</span> <span class='assign token'>=</span> <span class='target_slices identifier id'>target_slices</span>
<span class='puts identifier id'>puts</span> <span class='first_bit identifier id'>first_bit</span><span class='dot token'>.</span><span class='display_name identifier id'>display_name</span>      <span class='comment val'>#--&gt; scaffold:Btau_3.1:Chr4.003.105:42:599579:1</span>
<span class='puts identifier id'>puts</span> <span class='second_bit identifier id'>second_bit</span><span class='dot token'>.</span><span class='class identifier id'>class</span>        <span class='comment val'>#--&gt; Gap</span>
<span class='puts identifier id'>puts</span> <span class='third_bit identifier id'>third_bit</span><span class='dot token'>.</span><span class='display_name identifier id'>display_name</span>      <span class='comment val'>#--&gt; scaffold:Btau_3.1:Chr4.003.106:1:738311:1</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>coord_system_name</span>
      
      
      
        &mdash;
        <div class='inline'><p>
Name of coordinate system to project coordinates to
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span>, <span class='object_link'><a href="Gap.html" title="Ensembl::Core::Gap (class)">Gap</a></span>&gt;</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Array of Slices and, if necessary, Gaps
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/project.rb', line 53</span>

<span class='def def kw'>def</span> <span class='project identifier id'>project</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='rparen token'>)</span>
  <span class='answer identifier id'>answer</span> <span class='assign token'>=</span> <span class='Array constant id'>Array</span><span class='dot token'>.</span><span class='new identifier id'>new</span> <span class='comment val'># an array of slices</span>
  <span class='unless unless kw'>unless</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='coord_systems identifier id'>coord_systems</span><span class='dot token'>.</span><span class='has_key? fid id'>has_key?</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system_id identifier id'>coord_system_id</span><span class='rparen token'>)</span>
    <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='coord_systems identifier id'>coord_systems</span><span class='lbrack token'>[</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system_id identifier id'>coord_system_id</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span>
    <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='coord_system_ids identifier id'>coord_system_ids</span><span class='lbrack token'>[</span><span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='coord_systems identifier id'>coord_systems</span><span class='lbrack token'>[</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system_id identifier id'>coord_system_id</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system_id identifier id'>coord_system_id</span>
  <span class='end end kw'>end</span>
  <span class='source_coord_system identifier id'>source_coord_system</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='coord_systems identifier id'>coord_systems</span><span class='lbrack token'>[</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system_id identifier id'>coord_system_id</span><span class='rbrack token'>]</span>
  <span class='target_coord_system identifier id'>target_coord_system</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
  <span class='if if kw'>if</span> <span class='coord_system_name identifier id'>coord_system_name</span> <span class='eq op'>==</span> <span class='string val'>'toplevel'</span>
    <span class='target_coord_system identifier id'>target_coord_system</span> <span class='assign token'>=</span> <span class='source_coord_system identifier id'>source_coord_system</span><span class='dot token'>.</span><span class='find_toplevel identifier id'>find_toplevel</span>
  <span class='elsif elsif kw'>elsif</span> <span class='coord_system_name identifier id'>coord_system_name</span> <span class='eq op'>==</span> <span class='string val'>'seqlevel'</span>
    <span class='target_coord_system identifier id'>target_coord_system</span> <span class='assign token'>=</span> <span class='source_coord_system identifier id'>source_coord_system</span><span class='dot token'>.</span><span class='find_seqlevel identifier id'>find_seqlevel</span>
  <span class='else else kw'>else</span>
    <span class='unless unless kw'>unless</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='coord_system_ids identifier id'>coord_system_ids</span><span class='dot token'>.</span><span class='has_key? fid id'>has_key?</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='rparen token'>)</span>
      <span class='cs identifier id'>cs</span> <span class='assign token'>=</span> <span class='source_coord_system identifier id'>source_coord_system</span><span class='dot token'>.</span><span class='find_level identifier id'>find_level</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='rparen token'>)</span>
      <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='coord_systems identifier id'>coord_systems</span><span class='lbrack token'>[</span><span class='cs identifier id'>cs</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='cs identifier id'>cs</span>
      <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='coord_system_ids identifier id'>coord_system_ids</span><span class='lbrack token'>[</span><span class='cs identifier id'>cs</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='cs identifier id'>cs</span><span class='dot token'>.</span><span class='id identifier id'>id</span>
    <span class='end end kw'>end</span>
    <span class='target_coord_system identifier id'>target_coord_system</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='coord_systems identifier id'>coord_systems</span><span class='lbrack token'>[</span><span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='coord_system_ids identifier id'>coord_system_ids</span><span class='lbrack token'>[</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span>
  <span class='end end kw'>end</span>

  <span class='if if kw'>if</span> <span class='target_coord_system identifier id'>target_coord_system</span><span class='dot token'>.</span><span class='rank identifier id'>rank</span> <span class='lt op'>&lt;</span> <span class='source_coord_system identifier id'>source_coord_system</span><span class='dot token'>.</span><span class='rank identifier id'>rank</span>
    <span class='comment val'># We're going from component to assembly, which is easy.</span>
    <span class='assembly_links identifier id'>assembly_links</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='assembly_links_as_component identifier id'>assembly_links_as_component</span><span class='lparen token'>(</span><span class='source_coord_system identifier id'>source_coord_system</span><span class='rparen token'>)</span>
    
    <span class='if if kw'>if</span> <span class='assembly_links identifier id'>assembly_links</span><span class='dot token'>.</span><span class='length identifier id'>length</span> <span class='eq op'>==</span> <span class='integer val'>0</span>
      <span class='return return kw'>return</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
    <span class='else else kw'>else</span>
      <span class='assembly_links identifier id'>assembly_links</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='assembly_link identifier id'>assembly_link</span><span class='bitor op'>|</span>
        <span class='target_seq_region identifier id'>target_seq_region</span> <span class='assign token'>=</span> <span class='assembly_link identifier id'>assembly_link</span><span class='dot token'>.</span><span class='asm_seq_region identifier id'>asm_seq_region</span>
        <span class='target_start identifier id'>target_start</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='plus op'>+</span> <span class='assembly_link identifier id'>assembly_link</span><span class='dot token'>.</span><span class='asm_start identifier id'>asm_start</span> <span class='minus op'>-</span> <span class='assembly_link identifier id'>assembly_link</span><span class='dot token'>.</span><span class='cmp_start identifier id'>cmp_start</span>
        <span class='target_stop identifier id'>target_stop</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='plus op'>+</span> <span class='assembly_link identifier id'>assembly_link</span><span class='dot token'>.</span><span class='asm_start identifier id'>asm_start</span> <span class='minus op'>-</span> <span class='assembly_link identifier id'>assembly_link</span><span class='dot token'>.</span><span class='cmp_start identifier id'>cmp_start</span>
        <span class='target_strand identifier id'>target_strand</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='strand identifier id'>strand</span> <span class='mult op'>*</span> <span class='assembly_link identifier id'>assembly_link</span><span class='dot token'>.</span><span class='ori identifier id'>ori</span> <span class='comment val'># 1x1=&gt;1, 1x-1=&gt;-1, -1x-1=&gt;1</span>
        
        <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='target_seq_region identifier id'>target_seq_region</span><span class='comma token'>,</span> <span class='target_start identifier id'>target_start</span><span class='comma token'>,</span> <span class='target_stop identifier id'>target_stop</span><span class='comma token'>,</span> <span class='target_strand identifier id'>target_strand</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
      <span class='end end kw'>end</span>
    <span class='end end kw'>end</span>
    
  <span class='else else kw'>else</span>
    <span class='comment val'># If we're going from assembly to component, the answer of the target method</span>
    <span class='comment val'># is an array consisting of Slices intermitted with Gaps.</span>

    <span class='comment val'># ASSEMBLY_EXCEPTIONS</span>
    <span class='comment val'># CAUTION: there are exceptions to the assembly (stored in the assembly_exception)</span>
    <span class='comment val'># table which make things a little bit more difficult... For example,</span>
    <span class='comment val'># in human, the assembly data for the pseudo-autosomal region (PAR) of</span>
    <span class='comment val'># Y is *not* stored in the assembly table. Instead, there is a record</span>
    <span class='comment val'># in the assembly_exception table that says: &quot;For chr Y positions 1</span>
    <span class='comment val'># to 2709520, use chr X:1-2709520 for the assembly data.&quot;</span>
    <span class='comment val'># As a solution, what we'll do here, is split the assembly up in blocks:</span>
    <span class='comment val'># if a slice covers both the PAR and the allosomal region, we'll make</span>
    <span class='comment val'># two subslices (let's call them blocks not to intercede with the</span>
    <span class='comment val'># Slice#subslices method) and project these independently.</span>
    <span class='assembly_exceptions identifier id'>assembly_exceptions</span> <span class='assign token'>=</span> <span class='AssemblyException constant id'>AssemblyException</span><span class='dot token'>.</span><span class='find_all_by_seq_region_id identifier id'>find_all_by_seq_region_id</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='rparen token'>)</span>
    <span class='if if kw'>if</span> <span class='assembly_exceptions identifier id'>assembly_exceptions</span><span class='dot token'>.</span><span class='length identifier id'>length</span> <span class='gt op'>&gt;</span> <span class='integer val'>0</span>
      <span class='comment val'># Check if this bit of the original slice is covered in the</span>
      <span class='comment val'># assembly_exception table.</span>
      <span class='overlapping_exceptions identifier id'>overlapping_exceptions</span> <span class='assign token'>=</span> <span class='Array constant id'>Array</span><span class='dot token'>.</span><span class='new identifier id'>new</span>
      <span class='assembly_exceptions identifier id'>assembly_exceptions</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='ae identifier id'>ae</span><span class='bitor op'>|</span>
        <span class='if if kw'>if</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='comma token'>,</span> <span class='ae identifier id'>ae</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span><span class='comma token'>,</span> <span class='ae identifier id'>ae</span><span class='dot token'>.</span><span class='seq_region_end identifier id'>seq_region_end</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='overlaps? fid id'>overlaps?</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='rparen token'>)</span>
          <span class='if if kw'>if</span> <span class='ae identifier id'>ae</span><span class='dot token'>.</span><span class='exc_type identifier id'>exc_type</span> <span class='eq op'>==</span> <span class='string val'>'HAP'</span>
            <span class='raise identifier id'>raise</span> <span class='NotImplementedError constant id'>NotImplementedError</span><span class='comma token'>,</span> <span class='string val'>&quot;The haplotype exceptions are not implemented (yet). You can't project this slice.&quot;</span>
          <span class='end end kw'>end</span>
          <span class='overlapping_exceptions identifier id'>overlapping_exceptions</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='ae identifier id'>ae</span><span class='rparen token'>)</span>
        <span class='end end kw'>end</span>
      <span class='end end kw'>end</span>

      <span class='if if kw'>if</span> <span class='overlapping_exceptions identifier id'>overlapping_exceptions</span><span class='dot token'>.</span><span class='length identifier id'>length</span> <span class='gt op'>&gt;</span> <span class='integer val'>0</span>
        <span class='comment val'># First get all assembly blocks from chromosome Y</span>
        <span class='source_assembly_blocks identifier id'>source_assembly_blocks</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='excise identifier id'>excise</span><span class='lparen token'>(</span><span class='overlapping_exceptions identifier id'>overlapping_exceptions</span><span class='dot token'>.</span><span class='collect identifier id'>collect</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='e identifier id'>e</span><span class='bitor op'>|</span> <span class='e identifier id'>e</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span> <span class='dot2 op'>..</span> <span class='e identifier id'>e</span><span class='dot token'>.</span><span class='seq_region_end identifier id'>seq_region_end</span><span class='rbrace token'>}</span><span class='rparen token'>)</span>
        <span class='comment val'># And insert the blocks of chromosome X</span>
        <span class='all_assembly_blocks identifier id'>all_assembly_blocks</span> <span class='assign token'>=</span> <span class='Array constant id'>Array</span><span class='dot token'>.</span><span class='new identifier id'>new</span> <span class='comment val'>#both for chr X and Y</span>
        <span class='comment val'># First do all exceptions between the first and last block</span>
        <span class='previous_block identifier id'>previous_block</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
        <span class='source_assembly_blocks identifier id'>source_assembly_blocks</span><span class='dot token'>.</span><span class='sort_by identifier id'>sort_by</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='b identifier id'>b</span><span class='bitor op'>|</span> <span class='b identifier id'>b</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='rbrace token'>}</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='b identifier id'>b</span><span class='bitor op'>|</span>
          <span class='if if kw'>if</span> <span class='previous_block identifier id'>previous_block</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
            <span class='all_assembly_blocks identifier id'>all_assembly_blocks</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='b identifier id'>b</span><span class='rparen token'>)</span>
            <span class='previous_block identifier id'>previous_block</span> <span class='assign token'>=</span> <span class='b identifier id'>b</span>
            <span class='next next kw'>next</span>
          <span class='end end kw'>end</span>
          <span class='comment val'># Find the exception record</span>
          <span class='exception identifier id'>exception</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
          <span class='assembly_exceptions identifier id'>assembly_exceptions</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='ae identifier id'>ae</span><span class='bitor op'>|</span>
            <span class='if if kw'>if</span> <span class='ae identifier id'>ae</span><span class='dot token'>.</span><span class='seq_region_end identifier id'>seq_region_end</span> <span class='eq op'>==</span> <span class='b identifier id'>b</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='minus op'>-</span> <span class='integer val'>1</span>
              <span class='exception identifier id'>exception</span> <span class='assign token'>=</span> <span class='ae identifier id'>ae</span>
              <span class='break break kw'>break</span>
            <span class='end end kw'>end</span>
          <span class='end end kw'>end</span>

          <span class='new_slice_start identifier id'>new_slice_start</span> <span class='assign token'>=</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='exc_seq_region_start identifier id'>exc_seq_region_start</span> <span class='plus op'>+</span> <span class='lparen token'>(</span> <span class='previous_block identifier id'>previous_block</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='minus op'>-</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span> <span class='rparen token'>)</span>
          <span class='new_slice_stop identifier id'>new_slice_stop</span> <span class='assign token'>=</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='exc_seq_region_start identifier id'>exc_seq_region_start</span> <span class='plus op'>+</span> <span class='lparen token'>(</span> <span class='b identifier id'>b</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='minus op'>-</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span> <span class='rparen token'>)</span>
          <span class='new_slice_strand identifier id'>new_slice_strand</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='strand identifier id'>strand</span> <span class='mult op'>*</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='ori identifier id'>ori</span>
          <span class='new_slice identifier id'>new_slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='comma token'>,</span> <span class='SeqRegion constant id'>SeqRegion</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='exc_seq_region_id identifier id'>exc_seq_region_id</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='comma token'>,</span> <span class='new_slice_start identifier id'>new_slice_start</span><span class='comma token'>,</span> <span class='new_slice_stop identifier id'>new_slice_stop</span><span class='comma token'>,</span> <span class='new_slice_strand identifier id'>new_slice_strand</span><span class='rparen token'>)</span>

          <span class='all_assembly_blocks identifier id'>all_assembly_blocks</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='new_slice identifier id'>new_slice</span><span class='rparen token'>)</span>
          <span class='all_assembly_blocks identifier id'>all_assembly_blocks</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='b identifier id'>b</span><span class='rparen token'>)</span>
          <span class='previous_block identifier id'>previous_block</span> <span class='assign token'>=</span> <span class='b identifier id'>b</span>
        <span class='end end kw'>end</span>

        <span class='comment val'># And then see if we have to add an additional one at the start or end</span>
        <span class='first_block identifier id'>first_block</span> <span class='assign token'>=</span> <span class='source_assembly_blocks identifier id'>source_assembly_blocks</span><span class='dot token'>.</span><span class='sort_by identifier id'>sort_by</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='b identifier id'>b</span><span class='bitor op'>|</span> <span class='b identifier id'>b</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='rbrace token'>}</span><span class='lbrack token'>[</span><span class='integer val'>0</span><span class='rbrack token'>]</span>
        <span class='if if kw'>if</span> <span class='first_block identifier id'>first_block</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='gt op'>&gt;</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span>
          <span class='exception identifier id'>exception</span> <span class='assign token'>=</span> <span class='assembly_exceptions identifier id'>assembly_exceptions</span><span class='dot token'>.</span><span class='sort_by identifier id'>sort_by</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='ae identifier id'>ae</span><span class='bitor op'>|</span> <span class='ae identifier id'>ae</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span><span class='rbrace token'>}</span><span class='lbrack token'>[</span><span class='integer val'>0</span><span class='rbrack token'>]</span>
          <span class='new_slice_start identifier id'>new_slice_start</span> <span class='assign token'>=</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='exc_seq_region_start identifier id'>exc_seq_region_start</span> <span class='plus op'>+</span> <span class='lparen token'>(</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='minus op'>-</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span> <span class='rparen token'>)</span>
          <span class='new_slice_stop identifier id'>new_slice_stop</span> <span class='assign token'>=</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='exc_seq_region_start identifier id'>exc_seq_region_start</span> <span class='plus op'>+</span> <span class='lparen token'>(</span> <span class='first_block identifier id'>first_block</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='minus op'>-</span> <span class='integer val'>1</span> <span class='minus op'>-</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span> <span class='rparen token'>)</span>
          <span class='new_slice_strand identifier id'>new_slice_strand</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='strand identifier id'>strand</span> <span class='mult op'>*</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='ori identifier id'>ori</span>
          <span class='new_slice identifier id'>new_slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='comma token'>,</span> <span class='SeqRegion constant id'>SeqRegion</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='exc_seq_region_id identifier id'>exc_seq_region_id</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='comma token'>,</span> <span class='new_slice_start identifier id'>new_slice_start</span><span class='comma token'>,</span> <span class='new_slice_stop identifier id'>new_slice_stop</span><span class='comma token'>,</span> <span class='new_slice_strand identifier id'>new_slice_strand</span><span class='rparen token'>)</span>

          <span class='all_assembly_blocks identifier id'>all_assembly_blocks</span><span class='dot token'>.</span><span class='unshift identifier id'>unshift</span><span class='lparen token'>(</span><span class='new_slice identifier id'>new_slice</span><span class='rparen token'>)</span>
        <span class='end end kw'>end</span>

        <span class='last_block identifier id'>last_block</span> <span class='assign token'>=</span> <span class='source_assembly_blocks identifier id'>source_assembly_blocks</span><span class='dot token'>.</span><span class='sort_by identifier id'>sort_by</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='b identifier id'>b</span><span class='bitor op'>|</span> <span class='b identifier id'>b</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='rbrace token'>}</span><span class='lbrack token'>[</span><span class='integer val'>-1</span><span class='rbrack token'>]</span>
        <span class='if if kw'>if</span> <span class='last_block identifier id'>last_block</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='lt op'>&lt;</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span>
          <span class='exception identifier id'>exception</span> <span class='assign token'>=</span> <span class='assembly_exceptions identifier id'>assembly_exceptions</span><span class='dot token'>.</span><span class='sort_by identifier id'>sort_by</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='ae identifier id'>ae</span><span class='bitor op'>|</span> <span class='ae identifier id'>ae</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span><span class='rbrace token'>}</span><span class='lbrack token'>[</span><span class='integer val'>-1</span><span class='rbrack token'>]</span>
          <span class='new_slice_start identifier id'>new_slice_start</span> <span class='assign token'>=</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='exc_seq_region_start identifier id'>exc_seq_region_start</span> <span class='plus op'>+</span> <span class='lparen token'>(</span> <span class='last_block identifier id'>last_block</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='plus op'>+</span> <span class='integer val'>1</span> <span class='minus op'>-</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span> <span class='rparen token'>)</span>
          <span class='new_slice_stop identifier id'>new_slice_stop</span> <span class='assign token'>=</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='exc_seq_region_start identifier id'>exc_seq_region_start</span> <span class='plus op'>+</span> <span class='lparen token'>(</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='minus op'>-</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='seq_region_start identifier id'>seq_region_start</span> <span class='rparen token'>)</span>
          <span class='new_slice_strand identifier id'>new_slice_strand</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='strand identifier id'>strand</span> <span class='mult op'>*</span> <span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='ori identifier id'>ori</span>
          <span class='new_slice identifier id'>new_slice</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='comma token'>,</span> <span class='SeqRegion constant id'>SeqRegion</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='exception identifier id'>exception</span><span class='dot token'>.</span><span class='exc_seq_region_id identifier id'>exc_seq_region_id</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='comma token'>,</span> <span class='new_slice_start identifier id'>new_slice_start</span><span class='comma token'>,</span> <span class='new_slice_stop identifier id'>new_slice_stop</span><span class='comma token'>,</span> <span class='new_slice_strand identifier id'>new_slice_strand</span><span class='rparen token'>)</span>

          <span class='all_assembly_blocks identifier id'>all_assembly_blocks</span><span class='dot token'>.</span><span class='shift identifier id'>shift</span><span class='lparen token'>(</span><span class='new_slice identifier id'>new_slice</span><span class='rparen token'>)</span>
        <span class='end end kw'>end</span>

        <span class='answer identifier id'>answer</span> <span class='assign token'>=</span> <span class='Array constant id'>Array</span><span class='dot token'>.</span><span class='new identifier id'>new</span>
        <span class='all_assembly_blocks identifier id'>all_assembly_blocks</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='b identifier id'>b</span><span class='bitor op'>|</span>
          <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='b identifier id'>b</span><span class='dot token'>.</span><span class='project identifier id'>project</span><span class='lparen token'>(</span><span class='coord_system_name identifier id'>coord_system_name</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
        <span class='end end kw'>end</span>
        <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='flatten! fid id'>flatten!</span>

        <span class='return return kw'>return</span> <span class='answer identifier id'>answer</span>
      <span class='end end kw'>end</span>

    <span class='end end kw'>end</span>
    <span class='comment val'># END OF ASSEMBLY_EXCEPTIONS</span>

    <span class='comment val'># Get all AssemblyLinks starting from this assembly and for which</span>
    <span class='comment val'># the cmp_seq_region.coord_system is what we want.</span>
    <span class='assembly_links identifier id'>assembly_links</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='assembly_links_as_assembly identifier id'>assembly_links_as_assembly</span><span class='lparen token'>(</span><span class='target_coord_system identifier id'>target_coord_system</span><span class='rparen token'>)</span>

    <span class='comment val'># Now reject all the components that lie _before_ the source, then</span>
    <span class='comment val'># reject all the components that lie _after_ the source.</span>
    <span class='comment val'># Then sort based on their positions.</span>
    <span class='sorted_overlapping_assembly_links identifier id'>sorted_overlapping_assembly_links</span> <span class='assign token'>=</span> <span class='assembly_links identifier id'>assembly_links</span><span class='dot token'>.</span><span class='reject identifier id'>reject</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='al identifier id'>al</span><span class='bitor op'>|</span> <span class='al identifier id'>al</span><span class='dot token'>.</span><span class='asm_end identifier id'>asm_end</span> <span class='lt op'>&lt;</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='rbrace token'>}</span><span class='dot token'>.</span><span class='reject identifier id'>reject</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='al identifier id'>al</span><span class='bitor op'>|</span> <span class='al identifier id'>al</span><span class='dot token'>.</span><span class='asm_start identifier id'>asm_start</span> <span class='gt op'>&gt;</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='rbrace token'>}</span><span class='dot token'>.</span><span class='sort_by identifier id'>sort_by</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='al identifier id'>al</span><span class='bitor op'>|</span> <span class='al identifier id'>al</span><span class='dot token'>.</span><span class='asm_start identifier id'>asm_start</span><span class='rbrace token'>}</span>
    <span class='if if kw'>if</span> <span class='sorted_overlapping_assembly_links identifier id'>sorted_overlapping_assembly_links</span><span class='dot token'>.</span><span class='length identifier id'>length</span> <span class='eq op'>==</span> <span class='integer val'>0</span>
      <span class='return return kw'>return</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
    <span class='end end kw'>end</span>

    <span class='comment val'># What we'll do, is create slices for all the underlying components,</span>
    <span class='comment val'># including the first and the last one. At first, the first and last</span>
    <span class='comment val'># components are added in their entirety and will only be cropped afterwards.</span>
    <span class='previous_stop identifier id'>previous_stop</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
    <span class='sorted_overlapping_assembly_links identifier id'>sorted_overlapping_assembly_links</span><span class='dot token'>.</span><span class='each_index identifier id'>each_index</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='i identifier id'>i</span><span class='bitor op'>|</span>
      <span class='this_link identifier id'>this_link</span> <span class='assign token'>=</span> <span class='sorted_overlapping_assembly_links identifier id'>sorted_overlapping_assembly_links</span><span class='lbrack token'>[</span><span class='i identifier id'>i</span><span class='rbrack token'>]</span>
      <span class='if if kw'>if</span> <span class='i identifier id'>i</span> <span class='eq op'>==</span> <span class='integer val'>0</span>
        <span class='cmp_seq_region identifier id'>cmp_seq_region</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
        <span class='if if kw'>if</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='seq_regions identifier id'>seq_regions</span><span class='dot token'>.</span><span class='has_key? fid id'>has_key?</span><span class='lparen token'>(</span><span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='cmp_seq_region_id identifier id'>cmp_seq_region_id</span><span class='rparen token'>)</span>
          <span class='cmp_seq_region identifier id'>cmp_seq_region</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='seq_regions identifier id'>seq_regions</span><span class='lbrack token'>[</span><span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='cmp_seq_region_id identifier id'>cmp_seq_region_id</span><span class='rbrack token'>]</span>
        <span class='else else kw'>else</span>
          <span class='cmp_seq_region identifier id'>cmp_seq_region</span> <span class='assign token'>=</span> <span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='cmp_seq_region identifier id'>cmp_seq_region</span>
          <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='SESSION constant id'>SESSION</span><span class='dot token'>.</span><span class='seq_regions identifier id'>seq_regions</span><span class='lbrack token'>[</span><span class='cmp_seq_region identifier id'>cmp_seq_region</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='cmp_seq_region identifier id'>cmp_seq_region</span>
        <span class='end end kw'>end</span>
        <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='cmp_seq_region identifier id'>cmp_seq_region</span><span class='comma token'>,</span> <span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='cmp_start identifier id'>cmp_start</span><span class='comma token'>,</span> <span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='cmp_end identifier id'>cmp_end</span><span class='comma token'>,</span> <span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='ori identifier id'>ori</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
        <span class='next next kw'>next</span>
      <span class='end end kw'>end</span>
      <span class='previous_link identifier id'>previous_link</span> <span class='assign token'>=</span> <span class='sorted_overlapping_assembly_links identifier id'>sorted_overlapping_assembly_links</span><span class='lbrack token'>[</span><span class='i identifier id'>i</span><span class='minus op'>-</span><span class='integer val'>1</span><span class='rbrack token'>]</span>

      <span class='comment val'># If there is a gap with the previous link: add a gap</span>
      <span class='if if kw'>if</span> <span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='asm_start identifier id'>asm_start</span> <span class='gt op'>&gt;</span> <span class='lparen token'>(</span> <span class='previous_link identifier id'>previous_link</span><span class='dot token'>.</span><span class='asm_end identifier id'>asm_end</span> <span class='plus op'>+</span> <span class='integer val'>1</span> <span class='rparen token'>)</span>
        <span class='gap_size identifier id'>gap_size</span> <span class='assign token'>=</span> <span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='asm_start identifier id'>asm_start</span> <span class='minus op'>-</span> <span class='previous_link identifier id'>previous_link</span><span class='dot token'>.</span><span class='asm_end identifier id'>asm_end</span> <span class='minus op'>-</span> <span class='integer val'>1</span>
        <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='Gap constant id'>Gap</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='target_coord_system identifier id'>target_coord_system</span><span class='comma token'>,</span> <span class='gap_size identifier id'>gap_size</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
      <span class='end end kw'>end</span>

      <span class='comment val'># And add the component itself as a Slice</span>
      <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='cmp_seq_region identifier id'>cmp_seq_region</span><span class='comma token'>,</span> <span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='cmp_start identifier id'>cmp_start</span><span class='comma token'>,</span> <span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='cmp_end identifier id'>cmp_end</span><span class='comma token'>,</span> <span class='this_link identifier id'>this_link</span><span class='dot token'>.</span><span class='ori identifier id'>ori</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
    <span class='end end kw'>end</span>

    <span class='comment val'># Now see if we have to crop the first and/or last slice</span>
    <span class='first_link identifier id'>first_link</span> <span class='assign token'>=</span> <span class='sorted_overlapping_assembly_links identifier id'>sorted_overlapping_assembly_links</span><span class='lbrack token'>[</span><span class='integer val'>0</span><span class='rbrack token'>]</span>
    <span class='if if kw'>if</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='gt op'>&gt;</span> <span class='first_link identifier id'>first_link</span><span class='dot token'>.</span><span class='asm_start identifier id'>asm_start</span>
      <span class='if if kw'>if</span> <span class='first_link identifier id'>first_link</span><span class='dot token'>.</span><span class='ori identifier id'>ori</span> <span class='eq op'>==</span> <span class='integer val'>-1</span>
        <span class='answer identifier id'>answer</span><span class='lbrack token'>[</span><span class='integer val'>0</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='assign token'>=</span> <span class='first_link identifier id'>first_link</span><span class='dot token'>.</span><span class='cmp_start identifier id'>cmp_start</span> <span class='plus op'>+</span> <span class='lparen token'>(</span> <span class='first_link identifier id'>first_link</span><span class='dot token'>.</span><span class='asm_end identifier id'>asm_end</span> <span class='minus op'>-</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='rparen token'>)</span>
      <span class='else else kw'>else</span>
        <span class='answer identifier id'>answer</span><span class='lbrack token'>[</span><span class='integer val'>0</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='assign token'>=</span> <span class='first_link identifier id'>first_link</span><span class='dot token'>.</span><span class='cmp_start identifier id'>cmp_start</span> <span class='plus op'>+</span> <span class='lparen token'>(</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='minus op'>-</span> <span class='first_link identifier id'>first_link</span><span class='dot token'>.</span><span class='asm_start identifier id'>asm_start</span> <span class='rparen token'>)</span>
      <span class='end end kw'>end</span>
    <span class='end end kw'>end</span>

    <span class='last_link identifier id'>last_link</span> <span class='assign token'>=</span> <span class='sorted_overlapping_assembly_links identifier id'>sorted_overlapping_assembly_links</span><span class='lbrack token'>[</span><span class='integer val'>-1</span><span class='rbrack token'>]</span>
    <span class='if if kw'>if</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='lt op'>&lt;</span> <span class='last_link identifier id'>last_link</span><span class='dot token'>.</span><span class='asm_end identifier id'>asm_end</span>
      <span class='if if kw'>if</span> <span class='last_link identifier id'>last_link</span><span class='dot token'>.</span><span class='ori identifier id'>ori</span> <span class='eq op'>==</span> <span class='integer val'>-1</span>
        <span class='answer identifier id'>answer</span><span class='lbrack token'>[</span><span class='integer val'>-1</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='assign token'>=</span> <span class='last_link identifier id'>last_link</span><span class='dot token'>.</span><span class='cmp_start identifier id'>cmp_start</span> <span class='plus op'>+</span> <span class='lparen token'>(</span> <span class='last_link identifier id'>last_link</span><span class='dot token'>.</span><span class='asm_end identifier id'>asm_end</span> <span class='minus op'>-</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='rparen token'>)</span>
      <span class='else else kw'>else</span>
        <span class='answer identifier id'>answer</span><span class='lbrack token'>[</span><span class='integer val'>-1</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='assign token'>=</span> <span class='last_link identifier id'>last_link</span><span class='dot token'>.</span><span class='cmp_start identifier id'>cmp_start</span> <span class='plus op'>+</span> <span class='lparen token'>(</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='minus op'>-</span> <span class='last_link identifier id'>last_link</span><span class='dot token'>.</span><span class='asm_start identifier id'>asm_start</span> <span class='rparen token'>)</span>
      <span class='end end kw'>end</span>
    <span class='end end kw'>end</span>

    <span class='comment val'># And check if we have to add Ns at the front and/or back</span>
    <span class='if if kw'>if</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='lt op'>&lt;</span> <span class='first_link identifier id'>first_link</span><span class='dot token'>.</span><span class='asm_start identifier id'>asm_start</span>
      <span class='gap_size identifier id'>gap_size</span> <span class='assign token'>=</span> <span class='first_link identifier id'>first_link</span><span class='dot token'>.</span><span class='asm_start identifier id'>asm_start</span> <span class='minus op'>-</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span>
      <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='unshift identifier id'>unshift</span><span class='lparen token'>(</span><span class='Gap constant id'>Gap</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='target_coord_system identifier id'>target_coord_system</span><span class='comma token'>,</span> <span class='gap_size identifier id'>gap_size</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
    <span class='end end kw'>end</span>
    <span class='if if kw'>if</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='gt op'>&gt;</span> <span class='last_link identifier id'>last_link</span><span class='dot token'>.</span><span class='asm_end identifier id'>asm_end</span>
      <span class='gap_size identifier id'>gap_size</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span> <span class='minus op'>-</span> <span class='last_link identifier id'>last_link</span><span class='dot token'>.</span><span class='asm_end identifier id'>asm_end</span>
      <span class='answer identifier id'>answer</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='Gap constant id'>Gap</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='target_coord_system identifier id'>target_coord_system</span><span class='comma token'>,</span> <span class='gap_size identifier id'>gap_size</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
    <span class='end end kw'>end</span>
  <span class='end end kw'>end</span>
  <span class='return return kw'>return</span> <span class='answer identifier id'>answer</span>

<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="protein_align_features-instance_method">
  
    - (<tt>Array&lt;<span class='object_link'><a href="ProteinAlignFeature.html" title="Ensembl::Core::ProteinAlignFeature (class)">ProteinAlignFeature</a></span>&gt;</tt>) <strong>protein_align_features</strong>(analysis_name) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Get all ProteinAlignFeatures that are located on a Slice for a given
Analysis.
</p>
<p>
Pitfall: just looks at the CoordSystem that the Slice is located on. For
example, if a Slice is located on a SeqRegion on the
&#8216;chromosome&#8217; CoordSystem, but all protein_align_features are
annotated on SeqRegions of the &#8216;scaffold&#8217; CoordSystem, this
method will return an empty array.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='my_slice identifier id'>my_slice</span><span class='dot token'>.</span><span class='protein_align_features identifier id'>protein_align_features</span><span class='lparen token'>(</span><span class='string val'>'Uniprot'</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='feature identifier id'>feature</span><span class='bitor op'>|</span>
  <span class='puts identifier id'>puts</span> <span class='feature identifier id'>feature</span><span class='dot token'>.</span><span class='to_yaml identifier id'>to_yaml</span>
<span class='end end kw'>end</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>analysis_name</span>
      
      
      
        &mdash;
        <div class='inline'><p>
Name of analysis
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="ProteinAlignFeature.html" title="Ensembl::Core::ProteinAlignFeature (class)">ProteinAlignFeature</a></span>&gt;</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Array of ProteinAlignFeature objects
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


584
585
586
587
588
589
590
591</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 584</span>

<span class='def def kw'>def</span> <span class='protein_align_features identifier id'>protein_align_features</span><span class='lparen token'>(</span><span class='analysis_name identifier id'>analysis_name</span><span class='rparen token'>)</span>
  <span class='if if kw'>if</span> <span class='analysis_name identifier id'>analysis_name</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
    <span class='return return kw'>return</span> <span class='ProteinAlignFeature constant id'>ProteinAlignFeature</span><span class='dot token'>.</span><span class='find_by_sql identifier id'>find_by_sql</span><span class='lparen token'>(</span><span class='string val'>'SELECT * FROM protein_align_feature WHERE seq_region_id = '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='plus op'>+</span> <span class='string val'>' AND seq_region_start &gt;= '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='plus op'>+</span> <span class='string val'>' AND seq_region_end &lt;= '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='rparen token'>)</span>
  <span class='else else kw'>else</span>
    <span class='analysis identifier id'>analysis</span> <span class='assign token'>=</span> <span class='Analysis constant id'>Analysis</span><span class='dot token'>.</span><span class='find_by_logic_name identifier id'>find_by_logic_name</span><span class='lparen token'>(</span><span class='analysis_name identifier id'>analysis_name</span><span class='rparen token'>)</span>
    <span class='return return kw'>return</span> <span class='ProteinAlignFeature constant id'>ProteinAlignFeature</span><span class='dot token'>.</span><span class='find_by_sql identifier id'>find_by_sql</span><span class='lparen token'>(</span><span class='string val'>'SELECT * FROM protein_align_feature WHERE seq_region_id = '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='plus op'>+</span> <span class='string val'>' AND seq_region_start &gt;= '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='plus op'>+</span> <span class='string val'>' AND seq_region_end &lt;= '</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='plus op'>+</span> <span class='string val'>' AND analysis_id = '</span> <span class='plus op'>+</span> <span class='analysis identifier id'>analysis</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='rparen token'>)</span>
  <span class='end end kw'>end</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="repeatmasked_seq-instance_method">
  
    - (<tt>Object</tt>) <strong>repeatmasked_seq</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  <h3>Raises:</h3>
<ul class="raise">
  
    <li>
      
        <span class='type'>(<tt>NotImplementedError</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


360
361
362</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 360</span>

<span class='def def kw'>def</span> <span class='repeatmasked_seq identifier id'>repeatmasked_seq</span>
  <span class='raise identifier id'>raise</span> <span class='NotImplementedError constant id'>NotImplementedError</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="split-instance_method">
  
    - (<tt>Array&lt;<span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span>&gt;</tt>) <strong>split</strong>(max_size = 100000, overlap = 0) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Creates overlapping subslices for a given Slice.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='my_slice identifier id'>my_slice</span><span class='dot token'>.</span><span class='split identifier id'>split</span><span class='lparen token'>(</span><span class='integer val'>50000</span><span class='comma token'>,</span> <span class='integer val'>250</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='sub_slice identifier id'>sub_slice</span><span class='bitor op'>|</span>
  <span class='puts identifier id'>puts</span> <span class='sub_slice identifier id'>sub_slice</span><span class='dot token'>.</span><span class='display_name identifier id'>display_name</span>
<span class='end end kw'>end</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>max_size</span>
      
      
        <em class="default">(defaults to: <tt>100000</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Maximal size of subslices
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>overlap</span>
      
      
        <em class="default">(defaults to: <tt>0</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Overlap in bp between consecutive subslices
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span>&gt;</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Array of Slice objects
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


386
387
388
389
390
391
392
393
394
395</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 386</span>

<span class='def def kw'>def</span> <span class='split identifier id'>split</span><span class='lparen token'>(</span><span class='max_size identifier id'>max_size</span> <span class='assign token'>=</span> <span class='integer val'>100000</span><span class='comma token'>,</span> <span class='overlap identifier id'>overlap</span> <span class='assign token'>=</span> <span class='integer val'>0</span><span class='rparen token'>)</span>
  <span class='sub_slices identifier id'>sub_slices</span> <span class='assign token'>=</span> <span class='Array constant id'>Array</span><span class='dot token'>.</span><span class='new identifier id'>new</span>
  <span class='i identifier id'>i</span> <span class='assign token'>=</span> <span class='integer val'>0</span>
  <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='dot token'>.</span><span class='step identifier id'>step</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='length identifier id'>length</span><span class='comma token'>,</span> <span class='max_size identifier id'>max_size</span> <span class='minus op'>-</span> <span class='overlap identifier id'>overlap</span> <span class='minus op'>-</span> <span class='integer val'>1</span><span class='rparen token'>)</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='i identifier id'>i</span><span class='bitor op'>|</span>
    <span class='sub_slices identifier id'>sub_slices</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='sub_slice identifier id'>sub_slice</span><span class='lparen token'>(</span><span class='i identifier id'>i</span><span class='comma token'>,</span> <span class='i identifier id'>i</span> <span class='plus op'>+</span> <span class='max_size identifier id'>max_size</span> <span class='minus op'>-</span> <span class='integer val'>1</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
  <span class='end end kw'>end</span>
  <span class='i identifier id'>i</span> <span class='opasgn op'>-=</span> <span class='lparen token'>(</span><span class='overlap identifier id'>overlap</span> <span class='plus op'>+</span> <span class='integer val'>1</span><span class='rparen token'>)</span>
  <span class='sub_slices identifier id'>sub_slices</span><span class='dot token'>.</span><span class='push identifier id'>push</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='sub_slice identifier id'>sub_slice</span><span class='lparen token'>(</span><span class='i identifier id'>i</span> <span class='plus op'>+</span> <span class='max_size identifier id'>max_size</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
  <span class='return return kw'>return</span> <span class='sub_slices identifier id'>sub_slices</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="sub_slice-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span></tt>) <strong>sub_slice</strong>(start = self.start, stop = self.stop) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Take a sub_slice from an existing one.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='my_sub_slice identifier id'>my_sub_slice</span> <span class='assign token'>=</span> <span class='my_slice identifier id'>my_slice</span><span class='dot token'>.</span><span class='sub_slice identifier id'>sub_slice</span><span class='lparen token'>(</span><span class='integer val'>400</span><span class='comma token'>,</span><span class='integer val'>500</span><span class='rparen token'>)</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>start</span>
      
      
        <em class="default">(defaults to: <tt>self.start</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Start of subslice relative to slice
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
        <span class='name'>stop</span>
      
      
        <em class="default">(defaults to: <tt>self.stop</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Stop of subslice relative to slice
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span></tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
Slice object
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


372
373
374</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 372</span>

<span class='def def kw'>def</span> <span class='sub_slice identifier id'>sub_slice</span><span class='lparen token'>(</span><span class='start identifier id'>start</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='comma token'>,</span> <span class='stop identifier id'>stop</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='rparen token'>)</span>
  <span class='return return kw'>return</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='class identifier id'>class</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='comma token'>,</span> <span class='start identifier id'>start</span><span class='comma token'>,</span> <span class='stop identifier id'>stop</span><span class='comma token'>,</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='strand identifier id'>strand</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="variation_connection-instance_method">
  
    - (<tt>Object</tt>) <strong>variation_connection</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


623
624
625
626
627
628
629</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 623</span>

<span class='def def kw'>def</span> <span class='variation_connection identifier id'>variation_connection</span><span class='lparen token'>(</span><span class='rparen token'>)</span>
  <span class='if if kw'>if</span> <span class='notop op'>!</span><span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Variation constant id'>Variation</span><span class='colon2 op'>::</span><span class='DBConnection constant id'>DBConnection</span><span class='dot token'>.</span><span class='connected? fid id'>connected?</span>  
    <span class='host identifier id'>host</span><span class='comma token'>,</span><span class='user identifier id'>user</span><span class='comma token'>,</span><span class='password identifier id'>password</span><span class='comma token'>,</span><span class='db_name identifier id'>db_name</span><span class='comma token'>,</span><span class='port identifier id'>port</span><span class='comma token'>,</span><span class='species identifier id'>species</span><span class='comma token'>,</span><span class='release identifier id'>release</span> <span class='assign token'>=</span> <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Core constant id'>Core</span><span class='colon2 op'>::</span><span class='DBConnection constant id'>DBConnection</span><span class='dot token'>.</span><span class='get_info identifier id'>get_info</span>
    <span class='Ensembl constant id'>Ensembl</span><span class='colon2 op'>::</span><span class='Variation constant id'>Variation</span><span class='colon2 op'>::</span><span class='DBConnection constant id'>DBConnection</span><span class='dot token'>.</span><span class='connect identifier id'>connect</span><span class='lparen token'>(</span><span class='species identifier id'>species</span><span class='comma token'>,</span><span class='release identifier id'>release</span><span class='dot token'>.</span><span class='to_i identifier id'>to_i</span><span class='comma token'>,</span><span class='symbol val'>:username</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='user identifier id'>user</span><span class='comma token'>,</span> <span class='symbol val'>:password</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='password identifier id'>password</span><span class='comma token'>,</span><span class='symbol val'>:host</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='host identifier id'>host</span><span class='comma token'>,</span> <span class='symbol val'>:port</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='port identifier id'>port</span><span class='rparen token'>)</span>
  <span class='end end kw'>end</span>
  
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="within?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>within?</strong>(other_slice) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
The Slice#within? method checks if this slice is contained withing another
one. The other slice has to be on the same coordinate system
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4><div class='inline'></div></h4>
      <pre class="example code"><span class='slice_a identifier id'>slice_a</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='string val'>'chromosome'</span><span class='comma token'>,</span><span class='string val'>'X'</span><span class='comma token'>,</span><span class='integer val'>1</span><span class='comma token'>,</span><span class='integer val'>1000</span><span class='rparen token'>)</span>
<span class='slice_b identifier id'>slice_b</span> <span class='assign token'>=</span> <span class='Slice constant id'>Slice</span><span class='dot token'>.</span><span class='fetch_by_region identifier id'>fetch_by_region</span><span class='lparen token'>(</span><span class='string val'>'chromosome'</span><span class='comma token'>,</span><span class='string val'>'X'</span><span class='comma token'>,</span><span class='integer val'>900</span><span class='comma token'>,</span><span class='integer val'>950</span><span class='rparen token'>)</span>
<span class='if if kw'>if</span> <span class='slice_b identifier id'>slice_b</span><span class='dot token'>.</span><span class='overlaps? fid id'>overlaps?</span><span class='lparen token'>(</span><span class='slice_a identifier id'>slice_a</span><span class='rparen token'>)</span>
  <span class='puts identifier id'>puts</span> <span class='string val'>&quot;Slice b is within slice a&quot;</span>
<span class='end end kw'>end</span>
</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="Ensembl::Core::Slice (class)">Slice</a></span></tt>)</span>
      
      
        <span class='name'>other_slice</span>
      
      
      
        &mdash;
        <div class='inline'><p>
Another slice
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
        &mdash;
        <div class='inline'><p>
True if this slice is within other_slice, otherwise false
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ensembl/core/slice.rb', line 250</span>

<span class='def def kw'>def</span> <span class='within? fid id'>within?</span><span class='lparen token'>(</span><span class='other_slice identifier id'>other_slice</span><span class='rparen token'>)</span>
  <span class='if if kw'>if</span> <span class='notop op'>!</span> <span class='other_slice identifier id'>other_slice</span><span class='dot token'>.</span><span class='class identifier id'>class</span> <span class='eq op'>==</span> <span class='Slice constant id'>Slice</span>
    <span class='raise identifier id'>raise</span> <span class='RuntimeError constant id'>RuntimeError</span><span class='comma token'>,</span> <span class='string val'>&quot;The Slice#overlaps? method takes a Slice object as its arguments.&quot;</span>
  <span class='end end kw'>end</span>
  <span class='if if kw'>if</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span> <span class='neq op'>!=</span> <span class='other_slice identifier id'>other_slice</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span>
    <span class='raise identifier id'>raise</span> <span class='RuntimeError constant id'>RuntimeError</span><span class='comma token'>,</span> <span class='string val'>&quot;The argument slice of Slice#overlaps? has to be in the same coordinate system, but were &quot;</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='name identifier id'>name</span> <span class='plus op'>+</span> <span class='string val'>&quot; and &quot;</span> <span class='plus op'>+</span> <span class='other_slice identifier id'>other_slice</span><span class='dot token'>.</span><span class='seq_region identifier id'>seq_region</span><span class='dot token'>.</span><span class='coord_system identifier id'>coord_system</span><span class='dot token'>.</span><span class='name identifier id'>name</span>
  <span class='end end kw'>end</span>

  <span class='self_range identifier id'>self_range</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='dot2 op'>..</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span>
  <span class='other_range identifier id'>other_range</span> <span class='assign token'>=</span> <span class='other_slice identifier id'>other_slice</span><span class='dot token'>.</span><span class='start identifier id'>start</span> <span class='dot2 op'>..</span> <span class='other_slice identifier id'>other_slice</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span>

  <span class='if if kw'>if</span> <span class='other_range identifier id'>other_range</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='start identifier id'>start</span><span class='rparen token'>)</span> <span class='and and kw'>and</span> <span class='other_range identifier id'>other_range</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop identifier id'>stop</span><span class='rparen token'>)</span>
    <span class='return return kw'>return</span> <span class='true true kw'>true</span>
  <span class='else else kw'>else</span>
    <span class='return return kw'>return</span> <span class='false false kw'>false</span>
  <span class='end end kw'>end</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Wed Dec 15 19:18:21 2010 by 
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.6.3 (ruby-1.8.7).
</div>

  </body>
</html>